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 Reply

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

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube