Azure – Service Fabric – Create Hello World Project

Overview of Service Fabric
Service Fabric is a platform that makes it easy to package, deploy, and manage scalable and reliable microservices. Service Fabric is used for building and managing 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 micro services, please go through the article Microservices: An application revolution powered by the cloud
Open your favorite IDE Microsoft Visual Studio 2015 with 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 on OK button as shown below.

Stateful Service

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

Stateful Service
Stateful Service

Note: We can add any number of services to the project later.
Using the above Select a Template window, 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 following projects will be created.


We are now done 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 – Below is the code that gets created automatically in the HelloWorld Stateful Service project that we have created. A class named HelloWorldStatefulService inherited from the parent class named StatefulService


Below are the two functions that are created in our service HelloWorldStateful.

  • Create Service Replica Listeners – This method could be used for communicating with other Micro Services.
  • Run Async – This is the entry point of the service and could 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 the RunAsync method 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 the Start button as shown below.


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.


(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.


The above screen capture provides the details about the output of the RunAsync method.

  • Learned the prerequisits of developing the microservices using the Azure Service Fabric Platform.
  • How to create your basic first Azure Service Fabric Application.

One comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s