-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Closed
Description
Description
Your Azure credentials have not been set up or have expired, please run Connect-AzureRmAccount to set up your Azure credentials.
Despite this being Az, not AzureRM, we get an error that tells you to use Connect-AzureRmAccount?
Also, this code worked fine on Windows, Windows PowerShell, using AzureRm. When reloading the saved file, it's not logging you back in
Script/Steps for Reproduction
#region Login-Az()
Function Login-Az()
{
Param ([String]$Subscription, [String]$UPN)
$ProfilePath = (Split-Path $Profile.CurrentUserCurrentHost) + "/"
$AzContext = Import-AzContext -Path $($ProfilePath + $UPN + "@$Subscription.json") -ErrorAction SilentlyContinue
If ([string]::IsNullOrEmpty($AzContext))
{
$AzContext = Connect-AzAccount -Subscription $Subscription -Environment "AzureCloud"
Save-AzContext -Profile $AzContext -Path $($ProfilePath + $AzContext.Context.Account.Id + "@$Subscription.json") -Force
# Get-AzureRmContext
}
Else
{
Select-AzSubscription -Name $AzContext.Context.Subscription.Name -Context $AzContext.Context
}
Return $AzContext
}
#endregion Login-Az()
Module Version
Get-Module -ListAvailableEnvironment Data
$PSVersionTableDebug Output
Metadata
Metadata
Assignees
Labels
No labels