Creating a VMSS with Azure CLI
- Creating a resource group and then create the vmss
#!/bin/bash
# Create a resource group
az group create --name 'vmssdemo1' --location 'eastus'
# Create a VMSS
az vmss create `
--name 'myvmss' --resource-group 'vmssdemo1' --admin-username 'qtdevops' `
--admin-password 'learning@123' --authentication-type 'password' `
--image 'UbuntuLTS' --instance-count 2 `
--vm-sku 'Standard_B1s' --zones 1 2 3 `
--upgrade-policy-mode automatic `
--public-ip-per-vm
# install a sample application in the vmss
# script for installing application https://raw.githubusercontent.com/asquarezone/azurescripts/master/Oct21/installapache.sh
az vmss extension set --vmss-name 'myvmss' `
--name customScript --resource-group 'vmssdemo1' `
--version 2.0 --publisher Microsoft.Azure.Extensions `
--settings "{'commandToExecute':'sudo apt update && sudo apt install apache2 -y'}"
- Execute the following in your cli and verify if the vms in the scaleset have apache installed.
sudo service apache2 status
- Refer Here for vm extension troubleshooting
