Skip to content

Latest commit

 

History

History
 
 

04-cli

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Using Azure CLI & Cloud Shell

Azure CLI

Azure CLI Reference

Azure CLI Query

JMESPath Documentation

Extensions

Azure Account and Azure CLI Tools connect to Azure Cloud Shell

cloud-shell

Open the Cloud Shell to configure it for first use:

configure-cs

Chose Bash and your subscription

chose-bash

Note: Optional you can provide a meaningfull name to your Clould Shell Storage using Advanced Settings:

set-storage

Note: To reset CloudShell you can use Dismount-Clouddrive

Install Azure CLI on your local machine

Install Azure CLI in an elevated PowerShell prompt:

Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'; rm .\AzureCLI.msi

Note: To install Azure CLI in Linux (ie. WSL) execute install-az-cli.sh from Setup/windows-subsystem-linux folder

Azure CLI getting started

Log In:

az login

Try at cmd - use ctrl + d to exit:

az interactive

Note: You can also use: F1 - Open Bash in Cloud Shell using Azure Account Extension

open

List available extensions:

az extension list-available --output table
az extension add --name <extension-name>

Set Azrue CLI to auto-update:

az config set extension.use_dynamic_install=yes_without_prompt

List and set Subscriptions

List Subscriptions:

az account list -o table

Set default Subscription:

az account set --subscription <name or id>

Create an App Service to host a Web App:

rnd=$RANDOM
grp=az204-appservice-$rnd
appPlan=appservice-$rnd
web=foodweb-$rnd
loc=westeurope

# create a resource group
az group create -n $grp -l $loc

# create an App Service plan
az appservice plan create -n $appPlan -g $grp --sku B2

Note: You could also execute creat-app-service.azcli or run the following remote script in Cloud Shell

curl https://raw.githubusercontent.com/ARambazamba/AZ-204/master/Labs/create-lab-vm.sh | bash

Create a Lab VM

If you want to execute the labs on a machine where you have full controll please follow this guide:

  • Execute create-lab-vm.azcli
  • Wait unitl the machine has been pvovisioned
  • Connect to the VM using RDP
  • Execute Set-ExecutionPolicy bypass in an elevated prompt using run as administrator
  • Execute the script setup-az-204.ps1 in an elevated prompt

Note: To connect use the credientials from script create-lab-vm.azcli

rnd=$RANDOM
loc=westeurope
grp=az-lab
vmname=labvm-$rnd
user=azlabadmin
pwd=Lab@dmin1234
vmname=labvault-$rnd

az group create -n $grp -l $loc

az vm create -g $grp -n $vmname --admin-username $user --admin-password $pwd --image  MicrosoftWindowsDesktop:Windows-10:21h1-pro:19043.1237.2109130412 --size Standard_E2s_v3

Note: We are using this image and vm size because it supports nested virtualization

Reset Cloud Shell

To reset Cloud Shell you can use the following command:

couddrive unmount

or

Dismount-Clouddrive

Additional Labs & Walkthroughs

Control Azure services with the CLI