Deploying a Service Fabric cluster to run Windows containers

From container perspective, Service Fabric is a container orchestrator which supports both Windows and Linux containers. In legacy application lift and shift scenarios, we usually containerize the legacy application with minimal code change. And Service Fabric is a good platform to run these containers.

To deploy a Service Fabric cluster on Azure which is suitable for running containers, we can use ARM template. I created a template with the following special settings:

1 – An additional data disk is attached to the VMs in the cluster to host the downloaded container images. We need this disk is because by default all container images would be downloaded to C drive of the VMs. The C drive may run out of space if there are several large images downloaded.

[code lang=”HTML”] "dataDisks": [ { "lun": 0, "createOption": "Empty", "caching": "None", "managedDisk": { "storageAccountType": "Standard_LRS" }, "diskSizeGB": 100 } ] [/code]

2 – A custom script extension is used to run a custom script to format the data disk and change the configuration of dockerd service.

[code lang=”HTML”] { "properties": { "publisher": "Microsoft.Compute", "type": "CustomScriptExtension", "typeHandlerVersion": "1.9", "autoUpgradeMinorVersion": true, "settings": { "fileUris": [ "" ], "commandToExecute": "powershell -ExecutionPolicy Unrestricted -File config-docker.ps1" } }, "name": "VMCustomScriptVmExt_vmNodeType0Name" } [/code]

The customer script is as follows: