Skip to content

Instantly share code, notes, and snippets.

@MertSenel
Created August 22, 2020 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MertSenel/3d68e1e32b4d9b3ce51d521cbb0376b8 to your computer and use it in GitHub Desktop.
Save MertSenel/3d68e1e32b4d9b3ce51d521cbb0376b8 to your computer and use it in GitHub Desktop.
Deploy-AzARMTemplate-region2.ps1
#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