In this article, I am going to share my own experience and thought process since I could not find existing tutorials on how to do that. Recently, we have decided to install .NET Core runtime in the Service Fabric cluster to reduce the package size deployed to the cluster. It should reduce the deployment time for many .NET Core applications. Currently, we are using self-contained deployments, which result in deploying large packages that take a long time.


First attempt

In the beginning, I thought that this is a straightforward task to do, but I was so wrong. Why did I think that this is going to be easy? Well, we already had Terraform templates for the Service Fabric cluster and Virtual Machine Scale Sets (VMSS). We also had the .NET Framework 4.8 installation on VMSS via Powershell (.ps1) script added to the Terraform template as an extension to the VMSS.

extension {
	    name                       = "InstallDotNet"
	    publisher                  = "Microsoft.Compute"
	    type                       = "CustomScriptExtension"
	    type_handler_version       = "1.8"
	    auto_upgrade_minor_version = true
	    settings                   = <<EOF
	    {
	      "fileUris": [
	        "https://yourblobstorageaccount.blob.core.windows.net/dotnet48/InstallDotNet-48.ps1"
	      ],
	      "commandToExecute": "powershell -ExecutionPolicy Unrestricted -File InstallDotNet-48.ps1"
	    }
	    EOF
	  }

First, I decided to look for a .ps1 script that could install the runtime non-interactively. It turned out that Microsoft already had such a script. I thought, great let me download it and add to the existing Terraform VMSS configuration as an additional extension. I did that and the result looked good, so I created a Pull Request (PR). My coworkers reviewed it, and also Terraform validation passed. After completing the PR, the feature branch was merged to the dev branch, and automatic deployment started to the dev environment. As you might probably guess, it did not work quite well. Unfortunately, Azure does not support many extensions of the same type.

#azure #service-fabric #net-core #terraform #powershell

How to Install .Net Core Runtime in Service Fabric Using Terraform
9.35 GEEK