Azure Service Fabric - First Application

Overview of Service Fabric

Service Fabric is a platform, which makes it easy to package, deploy and manage scalable and reliable microservices. Service Fabric is used to build and manage these middle tier services.

In this article, we will learn how to create a basic ‘Hello World’ project, using Service Fabric.


  • Visual Studio 2015 (Update 2 or later)
  • Service Fabric Runtime and SDK
  • PowerShell 3.0 or higher.
  • Windows 8 or later (Windows 7 could also be used with PowerShell 3.0)

What are MicroServices?

To understand more about microservices, please go through the article Microservices: An application revolution powered by the cloud.

Open your favorite IDE Microsoft Visual Studio 2015 with an administrator mode. It’s mandatory that you open it in admin mode as VS will interact with SF (Service Fabric) runtime.

Create a New Project | Select Cloud in the Visual C# Templates | Select Service Fabric Application in the templates section | Provide a name to your project and finally click OK button, as shown below-

Visual C#

In the New Service Fabric Service Window, select Stateful service | Provide a Service Name | Click OK.

Visual C#

Note - We can add any number of Services to the project later.

Using the above, select a Templatewindow and you can create Applications, based on the available six templates. We will learn more about these templates in the future articles.

After a few seconds, the projects, given below, will be created-

Visual C#

We are now finished with creating the project. We will learn more about these two projects in the upcoming articles. Below is a glimpse of what these projects are-

  • HelloWorld – The Service Fabric Application – This project doesn’t have any code. However, it has some configuration related files.
  • HelloWorldStateful – The microservice - The code is given below to create automatically in the HelloWorld Stateful Service project , which has created a class named HelloWorldStatefulService inherited from the parent class named StatefulService.

Visual C#

The two functions are given below, which will be created in our Service HelloWorldStateful.

  • Create Service Replica Listeners – This method could be used for communicating with other microservices.
  • Run Async – This is the entry point of the Service and can be used for any kind of long running operations.

The RunAsync method is the entry point for the Service. We can replace the code, available in this method with our own logic, based on our requirements. The default implementation of RunAsyncmethod just has the functionality of incrementing the count and displaying the same in the diagnostic events.

Let’s run it by pressing Ctrl + F5 or Start button, as shown below-

Visual C#

After a few minutes, you will get a notification as shown below. I am using Windows 10 with Visual Studio 2015 as my development environment.

Visual C#

(We will learn what is this Service Fabric Local Cluster Manager in the upcoming articles.)

Below is the output of the program, which outputs a counter value in the Diagnostic Window.

Visual C#

The screenshot, shown above, provides the details about the output of the RunAsync method.

In your project requirements, you would implement some other logic in the RunAsync method. That’s it.


  1. We learned the prerequisites of developing the microservices, using Azure Service Fabric Platform.
  2. How to create your basic first Azure Service Fabric Application.

Hope, you enjoyed reading the article. Your comments are appreciated.