Friday, December 27, 2019

How to switch to different azure subscritption using powershell GET approach

Mac setup

Steps for Mac OS ( 10.2 or newer )

Install brew
Install Powershell Core ( brew cask install powershell )
Update brew and powershell ( brew update  ; brew cask install powershell ).
Install Azure Module ( pwsh  ps> Install-Module -Name Az -AllowClobber )
Install PSPKI ( for New-SelfSignedCertificateEx )
ps> Install-Module -Name PSPKI
ps> Import-Module -Name PSPKI

How to connect to the azure subscription using the Az powershell module ?

Install-Module -Name Az -AllowClobber

Then issue command:

Connect-AzAccount

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

New-AzResourceGroup -Name $resourcegroupname -Location $location

How to test the connectivity with that subscription ?

Get-AzVirtualBetworkGateway -Name <name of VPN gateway>  -ResourceGroupName <Resource group>

when you switch the subscription, need to follow these steps 

Uninstall-AzureRm

Install-Module -Name Az -AllowClobber


Then issue command:
Connect-AzAccount
New-AzResourceGroup -Name $resourcegroupname -Location $location

No comments:

Post a Comment