Created
August 22, 2020 03:37
-
-
Save MertSenel/3d68e1e32b4d9b3ce51d521cbb0376b8 to your computer and use it in GitHub Desktop.
Deploy-AzARMTemplate-region2.ps1
This file contains hidden or 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