Service Fabric 编程模型概述Service Fabric programming model overview

Service Fabric 提供了多种方法来编写和管理服务。Service Fabric offers multiple ways to write and manage your services. 服务可以选择使用 Service Fabric API 来充分利用平台的功能和应用程序框架。Services can choose to use the Service Fabric APIs to take full advantage of the platform's features and application frameworks. 服务还可以是采用任何语言编写的任意已编译可执行程序,也可以是在 Service Fabric 群集上托管的容器中运行的代码。Services can also be any compiled executable program written in any language or code running in a container hosted on a Service Fabric cluster.

来宾可执行文件Guest executables

来宾可执行文件是(采用任何语言编写的)任意现有可执行文件,可在应用程序中作为服务运行。A guest executable is an existing, arbitrary executable (written in any language) that can be run as a service in your application. 来宾可执行文件不直接调用 Service Fabric SDK API。Guest executables do not call the Service Fabric SDK APIs directly. 但是,它们仍受益于平台提供的功能,如服务可发现性、自定义运行状况和负载报告(通过调用 Service Fabric 公开的 REST API)。However they still benefit from features the platform offers, such as service discoverability, custom health and load reporting by calling REST APIs exposed by Service Fabric. 它们还具有完整的应用程序生命周期支持。They also have full application lifecycle support.

从部署第一个来宾可执行文件应用程序开始使用来宾可执行文件。Get started with guest executables by deploying your first guest executable application.


默认情况下,Service Fabric 以进程形式部署和激活这些服务。By default, Service Fabric deploys and activates services as processes. Service Fabric 还可以在容器中部署服务。Service Fabric can also deploy services in containers. Service Fabric 支持在 Windows Server 2016 及更高版本上部署 Linux 容器 和 Windows 容器。Service Fabric supports deployment of Linux containers and Windows containers on Windows Server 2016 and later. 可以从任何容器存储库中提取容器映像,并将其部署到计算机上。Container images can be pulled from any container repository and deployed to the machine. 可以在容器中将现有应用程序部署为来宾可执行文件、Service Fabric 无状态/有状态可靠服务或 Reliable Actors,并可以将进程中的服务和容器中的服务混用于同一应用程序。You can deploy existing applications as guest executables, Service Fabric stateless or stateful Reliable services or Reliable Actors in containers, and you can mix services in processes and services in containers in the same application.

了解有关在 Windows 或 Linux 中容器化服务的详细信息Learn more about containerizing your services in Windows or Linux

Reliable ServicesReliable Services

Reliable Services 是一个用于编写与 Service Fabric 平台集成的服务的轻型框架,并且受益于完整的平台功能集。Reliable Services is a light-weight framework for writing services that integrate with the Service Fabric platform and benefit from the full set of platform features. Reliable Services 提供最小 API 集合,该集合允许 Service Fabric 运行时管理服务的生命周期,以及允许服务与运行时进行交互。Reliable Services provide a minimal set of APIs that allow the Service Fabric runtime to manage the lifecycle of your services and that allow your services to interact with the runtime. 应用程序框架为最简化,可便于完全控制设计和实现选项,并可用于托管其他任何应用程序框架,如 ASP.NET Core。The application framework is minimal, giving you full control over design and implementation choices, and can be used to host any other application framework, such as ASP.NET Core.

Reliable Services 可以无状态,类似于大多数服务平台,如 Web 服务器。也就是说,创建的每个服务实例都是平等的,并且状态保存在外部解决方案中,如 Azure DB 或 Azure 表存储。Reliable Services can be stateless, similar to most service platforms, such as web servers, in which each instance of the service is created equal and state is persisted in an external solution, such as Azure DB or Azure Table Storage.

Reliable Services 也可以是有状态的,专门用于 Service Fabric,其状态使用 Reliable Collections 直接保存在服务本身中。Exclusive to Service Fabric, Reliable Services can also be stateful, where state is persisted directly in the service itself using Reliable Collections. 通过复制使状态具有高可用性,以及通过分区来分布状态,所有状态由 Service Fabric 自动管理。State is made highly-available through replication and distributed through partitioning, all managed automatically by Service Fabric.

详细了解 Reliable Services,或开始编写首个 Reliable Services 服务Learn more about Reliable Services or get started by writing your first Reliable Service.


ASP.NET Core 是一种开源跨平台框架,用于构建现代基于云的连接 Internet 的应用程序,如 Web 应用、IoT 应用和移动后端。ASP.NET Core is an open-source, cross-platform framework for building modern cloud-based Internet-connected applications, such as web apps, IoT apps, and mobile backends. Service Fabric 与 ASP.NET Core 集成,因此你可以编写无状态和有状态的 ASP.NET Core 应用程序,充分利用 Reliable Collections 和 Service Fabric 的高级编排功能。Service Fabric integrates with ASP.NET Core so you can write both stateless and stateful ASP.NET Core applications that take advantage of Reliable Collections and Service Fabric's advanced orchestration capabilities.

了解有关 Service Fabric 中 ASP.NET Core 的详细信息,或通过编写第一个 ASP.NET Core Service Fabric 应用程序开始使用。Learn more about ASP.NET Core in Service Fabric or get started by writing your first ASP.NET Core Service Fabric application.

Reliable ActorsReliable Actors

Reliable Actor 框架在 Reliable Services 的基础上生成,是基于计算性执行组件模型实现虚拟执行组件模式的应用程序框架。Built on top of Reliable Services, the Reliable Actor framework is an application framework that implements the Virtual Actor pattern, based on the computational actor model. Reliable Actor 框架通过称为“执行组件” 的单线程执行使用独立的计算单元和状态单元。The Reliable Actor framework uses independent units of compute and state with single-threaded execution called actors. Reliable Actor 为执行组件提供内置通信,以及提供预设的状态暂留和扩展配置。The Reliable Actor framework provides built-in communication for actors and pre-set state persistence and scale-out configurations.

由于 Reliable Actors 是在 Reliable Services 基础上构建的应用程序框架,因此它完全与 Service Fabric 平台集成,并且受益于平台所提供的完整功能集。Because Reliable Actors is an application framework built on Reliable Services, it is fully integrated with the Service Fabric platform and benefits from the full set of features offered by the platform.

详细了解 Reliable Actors,或开始编写首个 Reliable Actors 服务Learn more about Reliable Actors or get started by writing your first Reliable Actor service

使用 ASP.NET Core 构建前端服务Build a front end service using ASP.NET Core

后续步骤Next steps

Service Fabric 和容器概述Service Fabric and containers overview

Reliable Services 概述Reliable Services overview

Reliable Actors 概述Reliable Actors overview

Service Fabric 和 ASP.NET CoreService Fabric and ASP.NET Core