Tuesday, February 14, 2023

Azure Powershell commands

- To connect azure subscription from powershell.


Connect-AzAccount 

- if Connect-AzAccount does not connect properly use below command.

Connect-AzAccount -DeviceCode

WARNING: To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code D3DWL7T2R to authenticate.

- Type below command to check available subscription.

Get-AzSubscription

- To switch the subscription use below command.

Set-AzContext -Subscription {293caa52-ebff-42e6-9e6f-xxxxxxxx subscription id}

once you switch the subscription you can check resource of that subscription.


- Use below command to check resource group

Get-AzResourceGroup

use below to check formated info about resource group.

Get-AzResource | Format-Table

- use below command to create vm instance

New-AzVm -ResourceGroupName learn-6d075fba-929b-432a-89c7-xxxxxxx -Name "testvm-eus-01" -Credential (Get-Credential) -Location "eastus" -Image Canonical:0001-com-ubuntu-server-focal:20_04-lts:latest -OpenPorts 22 -PublicIpAddressName "testvm-01"




No comments: