Custom Script Extension - Gary-Moore/developmentwiki GitHub Wiki
The Custom Script Extension downloads and executes scripts on Azure virtual machines. This extension is useful for post deployment configuration, software installation, or any other configuration / management task. Scripts can be downloaded from Azure storage or GitHub, or provided to the Azure portal at extension run time. The Custom Script extension integrates with Azure Resource Manager templates, and can also be run using the Azure CLI, PowerShell, Azure portal, or the Azure Virtual Machine REST API.
Custom Link Extension Documentation
az vm extension set \
--resource-group ff5a02e5-7220-47f5-be00-27311b264c60 \
--vm-name myVM \
--name CustomScriptExtension \
--publisher Microsoft.Compute \
--settings '{"fileUris":["https://raw.githubusercontent.com/MicrosoftDocs/mslearn-welcome-to-azure/master/configure-iis.ps1"]}' \
--protected-settings '{"commandToExecute": "powershell -ExecutionPolicy Unrestricted -File configure-iis.ps1"}'
# Install IIS.
dism /online /enable-feature /featurename:IIS-WebServerRole
# Set the home page.
Set-Content `
-Path "C:\\inetpub\\wwwroot\\Default.htm" `
-Value "<html><body><h2>Welcome to Azure! My name is $($env:computername).</h2></body></html>"
az vm open-port \
--name myVM \
--resource-group ff5a02e5-7220-47f5-be00-27311b264c60 \
--port 80
az vm show \
--name myVM \
--resource-group [sandbox resource group name] \
--show-details \
--query [publicIps] \
--output tsv
az vm resize \
--resource-group [sandbox resource group name] \
--name myVM \
--size Standard_DS3_v2
az vm show \
--resource-group [sandbox resource group name] \
--name myVM \
--query "hardwareProfile" \
--output tsv