For anyone working with Service Fabric and wishing to build a solution targeting the .NET Framework 4.6, deploying to Azure is a challenge given this version of the framework is not yet available in the default Windows Server 2012 image.
To overcome the above limitation and to make the process as easy as possible, we’ll employ a customised Azure Resource Manager (ARM) template which we’ll first generate via the Azure Portal. To get started simply click on the following link https://portal.azure.com/#create/Microsoft.ServiceFabricCluster or in Azure Marketplace search for Service Fabric Cluster.
As there is great guidance and content on Microsoft’s Azure portal, I won’t repeat the steps on Deploying a Service Fabric Cluster using an ARM template however I will ask you to complete all the fields as you normally would (login, password, custom ports for http and https), but instead of pressing create and deploying your cluster we’ll opt to download the ARM template.
Opening the ARM template in Visual Code or your text editor of choice, search for the following json section:
Then add a custom script extension block with the following content:
Note, for additional security & flexibility self-host a copy of the InstallNetFx46.ps1 script file.
Download the ARM template, in my case I also rename the file to correspond to the environment targeted (for example AcmeServiceFabricUATCluster.json) and open a PowerShell window to the same folder. Then issue the following commands, substituting the Acme values for your own:
Get-AzureRmSubscription –SubscriptionName "AcmeCorp" | Select-AzureRmSubscription
New-AzureRmResourceGroup -Name AcmeUAT -Location "West US"
New-AzureRmResourceGroupDeployment -Name AcmeUATDeployment -ResourceGroupName AcmeUAT -TemplateFile AcmeServiceFabricUATCluster.json
Enter the values requested such as Password if executing interactively. Upon ARM completion your Service Fabric nodes will now contain an installation of .NET Framework 4.6… How simple! The next step is to deploy your solution…