This sample script runs on start up of the Linux VM and updates the packages
#!/bin/bash
offer=$(curl -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance/compute/offer?api-version=2020-09-01&format=text")
echo $offer
if [[ $offer == "UbuntuServer" ]]; then
sudo apt update
elif [[ $offer == "Centos" ]]; then
sudo yum update -y
else
echo "The current distribution $offer is not supported"
fi
Azure CLI
Ensure Azure CLI is installed on the machine
Now connect to Azure
az login
# once the login is success
az group list
Azure CLI is a command line utility which can be used to perform operations on Azure
Azure CLI commands will be in the following structure
az <service> [<sub section>] <action> --parameter1 <value1> ... --parametern <valuen>
Finding azure cli commands is very simple
Exercise:
Create a resource group in Azure using portal
Now lets see how to do the same stuff using azure cli. Navigate to Refer Here