Deploying Workloads on Azure using CLI/Powershell
- So far, we have been working on Azure VM or VMSS using Portal, In typical enterprise scenarios we are expected to create/maintain deployments of our application in an automated fashion.
- Azure Has 3 popular interfaces
- Portal
- Command line:
- Azure CLI
- Azure Powershell
- From Code:
- Azure SDK
- Lets start exploring command line.
Azure CLI
- Azure CLI is a set of commands to create/manage azure resources.
- Azure Commands will be in the form of
az service [sub service ] [sub service ] <action> <parameters>
- The sample azure cli command ignoring parameters or arguments
az group list
az sql server create
-
Install Azure CLI: Refer Here
-
Understanding JSON: Refer Here
-
Refer Here for the Azure CLI documentation.
-
Learning Activity 1: Using Azure CLI from cloud shell
- Navigate to Azure Portal and launch cloud shell and switch to bash

- Navigate to Azure Portal and launch cloud shell and switch to bash
-
Learning Activity 2: Create a resource group clidemo in eastus
- Documentation Navigation

- Command:
az group create --location 'eastus' --name 'clidemo'
- Documentation Navigation
-
Learning Activity 3: delete the resource group created clidemo
- Refer Here for the documentation
- command:
az group delete --name 'clidemo'
-
Learning Activity 4: Now lets try to create a Linux Virtual Machine and install apache inside the vm using cli
- Steps:
- Create a resource group
- Create a virutal machine
- find the documentation

- Using the documentation Refer Here try to come up with a command to create a ubuntu linux vm where we provide username, password, image
-
Waiting till 8:08 for you to come up with a command.
- find the documentation
- Open 80 port for web traffic
- connect to virtual machine
- Install webserver
- Test webserver from browser/curl
- Clean up resources
- Productivity Tips:
- Install the Azure CLI Tools extension to visual studio code

- Create a file with extension
.azcli
- Install the Azure CLI Tools extension to visual studio code
- Steps:
-
To find the correct vm image we need to know
- Publishers -> Offers -> Images -> Versions
az vm image list-publishers --location eastus --output table | less- Publisher => canonical
az vm image list-offers --location eastus --publisher canonical --output table- Offer => UbuntuServer
az vm image list --publisher canonical --offer 'UbuntuServer' --all --output table -
Now create a azure vm with the command

-
Commands
az group create --location 'eastus' --name 'linuxvm'
az vm create --resource-group 'linuxvm' --name 'qtwebserver' \
--admin-username 'qtdevops' --admin-password learning@123 \
--image 'Canonical:UbuntuServer:18.04-LTS:latest' \
--size 'Standard_B1s'
- Exercise: Create a windows 2016 server with size standard_b1s
