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 Services,或 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,也可以是具狀態的,其狀態會使用可靠的集合直接保存在服務本身。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 是一種開放原始碼、跨平臺的架構,可用於建立新式雲端式網際網路連線的應用程式,例如 web apps、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 整合,因此您可以同時撰寫能夠利用可靠集合和 Service Fabric 的進階協調流程功能的無狀態與具狀態的 ASP.NET Core 應用程式。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 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. 可靠的動作專案架構會使用獨立的計算單位和狀態,以及稱為動作專案的單一執行緒執行。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 Actor 服務開始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