Creating a secure Service Fabric Cluster in Microsoft Azure with internal load balancer on an existing virtual network– Part 1

In this post, I want to walk you through creating of a Service Fabric Cluster in Microsoft Azure, and make it a secure one. Moreover, we do not use the public IP address for the load balancer which is the default configuration of the Azure Portal when you are creating a Service Fabric. We will assign an internal IP address to the load balancer and place the Service Fabric on an Existing VNET in your Azure subscription.

I have divided this post into two parts:

Part1 – Creating a secure Service Fabric Cluster in Microsoft Azure with internal load balancer on an existing virtual LAN

Microsoft has a couple of articles on TechNet and MSDN regarding the steps involved in creating a Service fabric and customize it in a way that you can place it on your existing virtual network. In this article, I try to consolidate all those posts and walk you through this, step by step.

Step 1 – create the keyvault and certificates

To have a secure cluster in your Service Fabric cluster in Microsoft Azure, you need to create a certificate for your cluster and upload it to the Azure keyvault. Azure Service Fabric uses X.509 certificates to secure a cluster. In the production environment, your certificate file should be signed by an authoritative Certificate Authority. If you are creating this environment for your development or testing purposes, you can use a self-signed certificate to encrypt your cluster.

The process of creating certificate and upload it to keyvault to get the information you want is quite cumbersome in Powershell. Fortunately, there is a prepackaged Powershell cmdlets available for this purpose that you can use it. Here is the link:

you should clone or download the whole package from the github on your local computer, and then browse to the location and import the module:

1

Import-Module.\ServiceFabricRPHelpers.psm1

If you get an error when you want to run this cmdlet, it is possible that the file is being blocked because you have downloaded it from the public internet. You should right click on the file and unblock the psm1 and dll files in the folder and then import the module.

After that, run these commands to create a new self-signed certificate and upload it to Azure keyvault and get the required values:

1

2

3

4

5

6

7

8

9

$ResouceGroup="test_res_14"

$VName="liqsfvault"

$SubID=<your subscription id>

$locationRegion="westus2"

$newCertName="sfcert1"

$dnsName="*.liquwaresf.westus.cloudapp.azure.com"#The certificate's subject name must match the domain used to access the Service Fabric cluster.

$localCertPath="C:\MyCertificates"# location where you want the .PFX to be stored

It asks you for a password for the private key encryption. For the vault name, you should come up with a unique name. and, pay attention to the dns name to modify it in a way that suits you in the future. You can use wild character * to create a wildcard certificate for your Service Fabric cluster. Moreover, the location of the keyvault should be the same as the Service Fabric cluster that you want to create (in this example, westus2)

After you run these cmdlets successfully, you will get the values of these items:

CertificateThumbprint

SourceVault

CertificateURL

keep them in a text file. We need these values in the next steps.

Step 2 – generate the default Service Fabric ARM template

In this step, we use the Azure Portal to create a new Service Fabric cluster. We will fill out all the parameters and going to the end of the process. At the very last step, instead of creating the Service Fabric Cluster, we will download the ARM template for further modifications.

Login to the Azure portal and click on the new and search for the ‘service fabric’. Then click the Create button.

Enter the basic configuration parameters.

In the next step, select the node type count, and then configure each node type accordingly. For the first node type in your service fabric cluster, you need at least a scaleset of 5 instances of virtual machines.

Click ok and go to the step 3 for the security parameters. Click on the Secure mode and copy the values of the Powershell cmdlet output which you had run in the previous step and click ok.

In the step 4 Summary, you see the link to download the template.

Click on that to download the template.

In the next page you see the generated ARM template. Click on the download to download the ARM template.

A template.zip file will be downloaded in your local machine. Unzip it. There are multiple files with different formats. We need template.json to continue work on.

One thought on “Creating a secure Service Fabric Cluster in Microsoft Azure with internal load balancer on an existing virtual network– Part 1”

About SJ

Farshid Mahdavipour, MCSE, PMP
SharePoint Junkies (SJ) is a place to share my thoughts and experience on Microsoft technologies with the emphasize on Azure (IaaS, PaaS, SaaS), SharePoint Server and related products including Project Server, SQL Server … Information Architecture and IT governance is the main focus of this blog and also I will examine these products from administration and development viewpoints.