Deploy-AzARMTemplate-region2.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#region Connect to Correct Tenant and Subscription | |
$CurrentContext = Get-AzContext | |
#If there is no AzContext found connect to desired Subscription and Tenant | |
if (!$CurrentContext) { | |
Connect-AzAccount -Tenant $TenantId -Subscription $SubscriptionId -UseDeviceAuthentication | |
$CurrentContext = Get-AzContext | |
} | |
#If subscription ID doesnt match, call the Set-AzContext with | |
#SubscriptionId and TenantId to allow switch between tenants as well. | |
if ($CurrentContext.Subscription.Id -ne $SubscriptionId) { | |
$CurrentContext = Set-AzContext -Subscription $SubscriptionId -Tenant $TenantId | |
} | |
#endregion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment