Azure Classroom Series – 22/Oct/2021

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

Leave a comment

Turn on JavaScript to leave a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company
Exit mobile version
%%footer%%