Az-204 - Prep - How To - Creating VM Using Azure CLI - Bash

Hello Everyone, 

Please find below commands to create VM using azure cli `az`

# login and set a subscription
az login
az account set --subscription "Demo Account"

# List all created RGs
az group list --output table

# create a RG
az group create \
--name "psdemo-rg" \
--location "centralus"

# Creating a Windows VM
az vm create \
--resource-group "1-718a377a-playground-sandbox" \
--name "psdemo-win-cli" \
--image "win2019datacenter" \
--admin-username "demoadmin" \
--admin-password "password@123" \
--public-ip-sku "Standard"

# Open RDP Port for remote access (( Might open already))
az vm open-port \
--resource-group "1-718a377a-playground-sandbox" \
--name "psdemo-win-cli" \
--port "3389"

# get the Public IP Address for remote access
az vm list-ip-addresses \
--resource-group "1-718a377a-playground-sandbox" \
--name "psdemo-win-cli" \
--output table


# Creating a Linux VM
az vm create \
--resource-group "1-718a377a-playground-sandbox" \
--name "psdemo-linux-cli" \
--image "UbuntuLTS" \
--admin-username "demoadmin" \
--authentication "ssh" \
--ssh-key-value ~/.ssh/id_rsa.pub \
--public-ip-sku "Standard"

# open port 22 ((Might open already ))
az vm open-port \
--resource-group "1-718a377a-playground-sandbox" \
--name "psdemo-linux-cli" \
--port 22

# get the public IP Address
az vm list-ip-addresses \
--resource-group "1-718a377a-playground-sandbox" \
--name "psdemo-linux-cli" \
--output table

# verify login
ssh demoadmin@52.165.189.38


# Cleanup the resources
az group delete --name "1-718a377a-playground-sandbox"

Comments

Popular posts from this blog

grep: unknown device method

Uploading files to FTP/SFTP using CURL

How to find outgoing IP in Linux ?