The Az module in PowerShell Core is necessary for managing Azure resources. In this hands-on lab, we will show how to install the Az module and perform some basic commands for managing resources in Azure.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Log in to the VM
- Open a new terminal.
- Copy the public IP address, given to you along with this hands-on lab.
- In the terminal, enter
ssh cloud_user@<PUBLIC_IP_OF_THE_VM>
. - Once logged in, enter
pwsh
to start the PowerShell prompt.
- Install the Az PowerShell Module
Install the module:
Install-Module -Name Az -AllowClobber -Scope CurrentUser
Type
Y
to continue installing from the PowerShell gallery.
- Connect the Azure Account and Create a VM
- From the PowerShell prompt, enter the command
Connect-AzAccount
to connect to Azure. - Go to
https://microsoft.com/devicelogin
, and enter the code provided in the terminal. - Enter the username and password provided with this hands-on lab.
Enter the following to create a new Azure VM:
New-AzVM ` -ResourceGroupName '<RESOURCE_GROUP_NAME_PROVIDED_IN_LAB>' ` -Name 'myvm1234' ` -Location 'westus' ` -VirtualNetworkName '<VIRTUAL_NETWORK_NAME_PROVIDED_IN_LAB>' ` -SubnetName 'default' ` -SecurityGroupName '<NSG_PROVIDED_WITH_LAB>' ` -PublicIpAddressName 'myvm1234pubip' ` -OpenPorts 80,3389
- From the PowerShell prompt, enter the command