Microservices with the Azure Service Fabric SDK

Alberto De Natale
3 min readOct 18, 2019

--

This post is about how to develop microservices using the Azure Service Fabric SDK and how to deploy them on a local cluster.

Service Fabric, concepts

A very good page to grasp the basics:

I found this picture contains all the basic components of an SF Application:

  • Applications, identifiable by a URI in the form “fabric:/MyApp1”
  • Services, identifiable by a URI in the form “fabric:/MyApp1/SatelessSvcA
  • Partitions and Replicas, won’t use them here

The application

I created a simple application with two services, a front-end and a back-end.

Adding the SDK

The SF SDK requires a separate project to be created that will reference all the others. This project contains a PowerShell script called “Deploy-FabricApplication.ps1" responsible to read the cluster and the services configuration and apply it.

The “ApplicationManifest.xml” file defines the services present in the application and references the “ServiceManifest.xml” that are present in the solution

Run the project

Once run, the project will be published by Visual Studio into the local running instance of the “Service Fabric Local Cluster Manager”:

The website will respond at the endpoint defined into “Frontend/PackageRoot/ServiceManifest.xml”.

Using HttpClient

Services are not statically allocated to a single machine and they may move during their lifespan depending on scheduling decisions made by Azure Service Cluster.

In order for a service to communicate with another using HTTP, the service will have to resolve their IP and there are at least two ways for doing so:

  • DNS Protocol
  • Reverse Proxy

I will use a reverse proxy here, that is enabled by default on a dev cluster as shown in this answer:

Summary

Azure Service Fabric is the Microsoft Orchestrator. As you would expect from Microsoft, it offers very intuitively and easy to use tools.

--

--

Alberto De Natale
Alberto De Natale

Written by Alberto De Natale

Alberto De Natale is a passionate tech-enthusiast software developer.

No responses yet