How to change Azure Subscription in PowerShell?

PowerShellMicrosoft TechnologiesSoftware & Coding

To change the azure subscription using PowerShell, we can use the Select-AZSubscription command. When you use this command, you can use either the subscription ID, Subscription Name, or the Tenant ID.

Example

With Subscription Name,

Select-AzSubscription -SubscriptionName 'Visual Studio'

With TenantID,

Select-AzSubscription -Tenant 'XXXX-XXXXX-XXXXXXX-XXXX'

With Subscription ID,

Select-AzSubscription -SubscriptionId 'XXXX-XXXXX-XXXXXXX-XXXX'

Sometimes on console messages will appear that one or more subscriptions are active. In that case, you can switch the other subscription using the Set-AZContext command and you can use subscription ID or the Name for it.

Example

Set-AzContext -SubscriptionId "xxxx-xxxx-xxxx-xxxx"

Or

Set-AzContext -SubscriptionName "Visual Studio"
raja
Published on 04-Jan-2021 10:04:59
Advertisements