Need custom data in azure virtual machine scaleset (Windows) to install IIS server and replace the default iis page echoing hostname of the server. Appreciate any guidance in this regard,
Asked
Active
Viewed 570 times
1 Answers
0
For your requirements, I would like to recommend Azure Custom Script Extension on your virtual machine scale sets.
Here is an official sample. This installs the IIS web server and outputs the hostname of the scale set VM instance. The Custom Script Extension definition downloads a sample script from GitHub, installs the required packages, then writes the VM instance hostname to a basic HTML page.
$customConfig = @{
"fileUris" = (,"https://raw.githubusercontent.com/Azure-Samples/compute-automation-configurations/master/automate-iis.ps1");
"commandToExecute" = "powershell -ExecutionPolicy Unrestricted -File automate-iis.ps1"
}
# Get information about the scale set
$vmss = Get-AzVmss `
-ResourceGroupName "myResourceGroup" `
-VMScaleSetName "myScaleSet"
# Add the Custom Script Extension to install IIS and configure basic website
$vmss = Add-AzVmssExtension `
-VirtualMachineScaleSet $vmss `
-Name "customScript" `
-Publisher "Microsoft.Compute" `
-Type "CustomScriptExtension" `
-TypeHandlerVersion 1.9 `
-Setting $customConfig
# Update the scale set and apply the Custom Script Extension to the VM instances
Update-AzVmss `
-ResourceGroupName "myResourceGroup" `
-Name "myScaleSet" `
-VirtualMachineScaleSet $vmss

Nancy
- 26,865
- 3
- 18
- 34
-
Thank you so much. It worked wonders. Appreciated your help, – Pawan Modi May 06 '21 at 15:56
-
@PawanModi Glad to hear that my reply helped. Do you mind accepting this answer like [this](https://stackoverflow.com/help/someone-answers)? Other members in SO would also benefit from this answer. – Nancy May 10 '21 at 02:32