azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Import-AzureRmContext unable to use

Open kuomingwu opened this issue 9 years ago • 55 comments

Description

We unable to use Import-AzureRmContext but show failed and we found this function should able to implement on ver 3.8.0 (https://docs.microsoft.com/en-us/powershell/azure/release-notes-azureps?view=azurermps-4.0.0)

Error message as below :

  • Import-AzureRmContext

    • CategoryInfo : ObjectNotFound: (Import-AzureRmContext:String) [], CommandNotFoundException
    • FullyQualifiedErrorId : CommandNotFoundException

Obsolete: Select-AzureRmProfile is renamed to Import-AzureRmContext, there is an alias to the old cmdlet name, the alias will be removed in the next release.

kuomingwu avatar May 12 '17 02:05 kuomingwu

Regarding version 4.0.0

Cmdlet 'Import-AzureRmContext' does not have an alias, neither is this cmdlet functional. When I save the AzureRmContex I am able to save data to the defined JSON file. However when I import this JSON file (which is successful) I get an error message when running cmdlet 'Get-AzureRmResourceGroup'!

==== NO ALIAS ========================================================

C:\Temp> Get-Alias -Definition Import-AzureRmContext Get-Alias : This command cannot find a matching alias because an alias with the definition 'Import-AzureRmContext' does not exist. At line:1 char:1

  • Get-Alias -Definition Import-AzureRmContext
  •  + CategoryInfo          : ObjectNotFound: (Import-AzureRmContext:String) [Get-Alias], ItemNotFoundException
      + FullyQualifiedErrorId : ItemNotFoundException,Microsoft.PowerShell.Commands.GetAliasCommand
    
    
    

==== NOT FUNCTIONAL ==================================================

C:\Temp> Add-AzureRmAccount

Environment : AzureCloud Account : MarcTest@.onmicrosoft.com TenantId : 7dfbbf2 SubscriptionId : bc6********b1e5 SubscriptionName : Visual Studio Enterprise CurrentStorageAccount :

C:\Temp> Save-AzureRmContext -Path "C:\Temp\Marc1.json" C:\Temp> C:\Temp> Add-AzureRmAccount

Environment : AzureCloud Account : anl2***@ud.eu TenantId : 62c1dc0 SubscriptionId : 692***c8b3 SubscriptionName : *******************Development1 CurrentStorageAccount :

C:\Temp> Save-AzureRmContext -Path "C:\Temp\Marc2.json" C:\Temp> C:\Temp> Import-AzureRmContext -Path "C:\Temp\Marc1.json"

Environment : AzureCloud Account : MarcTest@.onmicrosoft.com TenantId : 7dfbbf2 SubscriptionId : bc6********b1e5 SubscriptionName : Visual Studio Enterprise CurrentStorageAccount :

C:\Temp> Get-AzureRmResourceGroup Get-AzureRmResourceGroup : Your Azure credentials have not been set up or have expired, please run Login-AzureRMAccount to set up your Azure credentials. At line:1 char:1

  • Get-AzureRmResourceGroup
  •   + CategoryInfo          : CloseError: (:) [Get-AzureRmResourceGroup], ArgumentException
      + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.GetAzureResourceGroupCmdlet
    
    

C:\Temp>

Marc013 avatar May 12 '17 09:05 Marc013

@Marc013 Can you run Get-Module -ListAvailable and provide the set of installed modules?

Import-AzureRmContext is indeed, not an alias. And we can't repro this issue, so either there is something special about your environment or your credentials that we need to suss out.

markcowl avatar May 12 '17 17:05 markcowl

@kuomingwu Yes, the unfortunate obsolete warning is a known issue: https://github.com/Azure/azure-powershell/issues/3822

However the cmdlet does exist - I'm not clear on exactly the behavior you are seeing with 3.8 when you type

Import-AzureRmContext -Path <path to file>

Can you please clarify?

markcowl avatar May 12 '17 17:05 markcowl

@markcowl Herewith the information you requested + the PowerShell version I have on my Windows 10 system.

I adjusted the formatting to make the outcome readable.

C:\> $PSVersionTable
Name Value
PSVersion 5.1.14393.1198
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.1198
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
C:\> Get-Module -ListAvailable
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
Script 4.0.0 Azure {Get-AzureAutomationCertificate, Get-AzureAutomationConnection, New-AzureAutomationConnection...
Script 0.3.0 Azure.AnalysisServices {Add-AzureAnalysisServicesAccount, Restart-AzureAnalysisServicesInstance, Login-AzureAsAccoun...
Script 3.0.0 Azure.Storage {Get-AzureStorageTable, New-AzureStorageTableSASToken, New-AzureStorageTableStoredAccessPolic...
Binary 2.0.0.115 AzureAD {Add-AzureADApplicationOwner, Get-AzureADApplication, Get-AzureADApplicationExtensionProperty...
Script 0.2.3.8 AzureAutomationAuthoringToolkit {Get-AutomationVariable, Get-AutomationCertificate, Get-AutomationPSCredential, Get-Automatio...
Script 4.0.0 AzureRM
Script 0.3.0 AzureRM.AnalysisServices {Resume-AzureRmAnalysisServicesServer, Suspend-AzureRmAnalysisServicesServer, Get-AzureRmAnal...
Script 4.0.0 AzureRM.ApiManagement {Add-AzureRmApiManagementRegion, Get-AzureRmApiManagementSsoToken, New-AzureRmApiManagementHo...
Script 3.0.0 AzureRM.Automation {Get-AzureRMAutomationHybridWorkerGroup, Get-AzureRmAutomationJobOutputRecord, Import-AzureRm...
Script 3.0.0 AzureRM.Backup {Backup-AzureRmBackupItem, Enable-AzureRmBackupContainerReregistration, Get-AzureRmBackupCont...
Script 3.0.0 AzureRM.Batch {Remove-AzureRmBatchAccount, Get-AzureRmBatchAccount, Get-AzureRmBatchAccountKeys, New-AzureR...
Script 0.12.0 AzureRM.Billing {Get-AzureRmBillingInvoice, Get-AzureRmBillingPeriod}
Script 3.0.0 AzureRM.Cdn {Get-AzureRmCdnProfile, Get-AzureRmCdnProfileSsoUrl, New-AzureRmCdnProfile, Remove-AzureRmCdn...
Script 0.7.0 AzureRM.CognitiveServices {Get-AzureRmCognitiveServicesAccount, Get-AzureRmCognitiveServicesAccountKey, Get-AzureRmCogn...
Script 3.0.0 AzureRM.Compute {Remove-AzureRmAvailabilitySet, Get-AzureRmAvailabilitySet, New-AzureRmAvailabilitySet, Updat...
Script 0.1.0 AzureRM.Consumption Get-AzureRmConsumptionUsageDetail
Script 0.1.0 AzureRM.ContainerRegistry {New-AzureRmContainerRegistry, Get-AzureRmContainerRegistry, Update-AzureRmContainerRegistry,...
Script 3.0.0 AzureRM.DataFactories {Remove-AzureRmDataFactory, Get-AzureRmDataFactoryRun, Get-AzureRmDataFactorySlice, Save-Azur...
Script 3.0.0 AzureRM.DataLakeAnalytics {Get-AzureRmDataLakeAnalyticsDataSource, New-AzureRmDataLakeAnalyticsCatalogCredential, Remov...
Script 4.0.0 AzureRM.DataLakeStore {Get-AzureRmDataLakeStoreTrustedIdProvider, Remove-AzureRmDataLakeStoreTrustedIdProvider, Rem...
Script 3.0.0 AzureRM.DevTestLabs {Get-AzureRmDtlAllowedVMSizesPolicy, Get-AzureRmDtlAutoShutdownPolicy, Get-AzureRmDtlAutoStar...
Script 3.0.0 AzureRM.Dns {Get-AzureRmDnsRecordSet, New-AzureRmDnsRecordConfig, Remove-AzureRmDnsRecordSet, Set-AzureRm...
Script 0.3.0 AzureRM.EventHub {New-AzureRmEventHubKey, Get-AzureRmEventHubNamespace, Get-AzureRmEventHubNamespaceAuthorizat...
Script 3.0.0 AzureRM.HDInsight {Get-AzureRmHDInsightJob, New-AzureRmHDInsightSqoopJobDefinition, Wait-AzureRmHDInsightJob, N...
Script 3.0.0 AzureRM.Insights {Get-AzureRmUsage, Get-AzureRmMetricDefinition, Get-AzureRmMetric, Remove-AzureRmLogProfile...}
Script 2.0.0 AzureRM.IotHub {Add-AzureRmIotHubKey, Get-AzureRmIotHubEventHubConsumerGroup, Get-AzureRmIotHubConnectionStr...
Script 3.0.0 AzureRM.KeyVault {Add-AzureKeyVaultCertificate, Set-AzureKeyVaultCertificateAttribute, Stop-AzureKeyVaultCerti...
Script 3.0.0 AzureRM.LogicApp {Get-AzureRmIntegrationAccountAgreement, Get-AzureRmIntegrationAccountCallbackUrl, Get-AzureR...
Script 0.14.0 AzureRM.MachineLearning {Move-AzureRmMlCommitmentAssociation, Get-AzureRmMlCommitmentAssociation, Get-AzureRmMlCommit...
Script 0.6.0 AzureRM.Media {Sync-AzureRmMediaServiceStorageKeys, Set-AzureRmMediaServiceKey, Get-AzureRmMediaServiceKeys...
Script 4.0.0 AzureRM.Network {Add-AzureRmApplicationGatewayAuthenticationCertificate, Get-AzureRmApplicationGatewayAuthent...
Script 3.0.0 AzureRM.NotificationHubs {Get-AzureRmNotificationHub, Get-AzureRmNotificationHubAuthorizationRules, Get-AzureRmNotific...
Script 3.0.0 AzureRM.OperationalInsights {New-AzureRmOperationalInsightsAzureActivityLogDataSource, New-AzureRmOperationalInsightsCust...
Script 3.0.0 AzureRM.PowerBIEmbedded {Remove-AzureRmPowerBIWorkspaceCollection, Get-AzureRmPowerBIWorkspaceCollection, Get-AzureRm...
Script 3.0.0 AzureRM.profile {Disable-AzureRmDataCollection, Enable-AzureRmDataCollection, Remove-AzureRmEnvironment, Get-...
Script 3.0.0 AzureRM.RecoveryServices {Get-AzureRmRecoveryServicesBackupProperty, Get-AzureRmRecoveryServicesVault, Get-AzureRmReco...
Script 3.0.0 AzureRM.RecoveryServices.Backup {Backup-AzureRmRecoveryServicesBackupItem, Get-AzureRmRecoveryServicesBackupManagementServer,...
Script 3.0.0 AzureRM.RedisCache {Remove-AzureRmRedisCachePatchSchedule, New-AzureRmRedisCacheScheduleEntry, Get-AzureRmRedisC...
Script 0.1.0 AzureRM.Relay {New-AzureRmRelayNamespace, Get-AzureRmRelayNamespace, Set-AzureRmRelayNamespace, Remove-Azur...
Script 4.0.0 AzureRM.Resources {Get-AzureRmProviderOperation, Remove-AzureRmRoleAssignment, Get-AzureRmRoleAssignment, New-A...
Script 0.14.0 AzureRM.Scheduler {Disable-AzureRmSchedulerJobCollection, Enable-AzureRmSchedulerJobCollection, Get-AzureRmSche...
Script 3.0.0 AzureRM.ServerManagement {Invoke-AzureRmServerManagementPowerShellCommand, Get-AzureRmServerManagementSession, New-Azu...
Script 0.3.0 AzureRM.ServiceBus {Get-AzureRmServiceBusTopic, Get-AzureRmServiceBusTopicAuthorizationRule, Get-AzureRmServiceB...
Script 0.1.0 AzureRM.ServiceFabric {Add-AzureRmServiceFabricApplicationCertificate, Add-AzureRmServiceFabricClientCertificate, A...
Script 4.0.0 AzureRM.SiteRecovery {Get-AzureRmSiteRecoveryFabric, New-AzureRmSiteRecoveryFabric, Remove-AzureRmSiteRecoveryFabr...
Script 3.0.0 AzureRM.Sql {Get-AzureRmSqlDatabaseTransparentDataEncryption, Get-AzureRmSqlDatabaseTransparentDataEncryp...
Script 3.0.0 AzureRM.Storage {Get-AzureRmStorageAccount, Get-AzureRmStorageAccountKey, New-AzureRmStorageAccount, New-Azur...
Script 3.0.0 AzureRM.StreamAnalytics {Get-AzureRmStreamAnalyticsFunction, Get-AzureRmStreamAnalyticsDefaultFunctionDefinition, New...
Script 3.0.0 AzureRM.Tags {Remove-AzureRmTag, Get-AzureRmTag, New-AzureRmTag}
Script 3.0.0 AzureRM.TrafficManager {Disable-AzureRmTrafficManagerEndpoint, Enable-AzureRmTrafficManagerEndpoint, Set-AzureRmTraf...
Script 3.0.0 AzureRM.UsageAggregates Get-UsageAggregates
Script 3.0.0 AzureRM.Websites {Get-AzureRmAppServicePlan, Set-AzureRmAppServicePlan, New-AzureRmAppServicePlan, Remove-Azur...
Script 1.0 ISEScriptAnalyzerAddOn
Script 1.0.1 Microsoft.PowerShell.Operation.V... {Get-OperationValidation, Invoke-OperationValidation}
Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Script 4.0.3 Pester {Describe, Context, It, Should...}
Script 0.7.0 posh-git {Invoke-NullCoalescing, Add-PoshGitToProfile, Write-GitStatus, Write-Prompt...}
Script 1.0.0.1 PowerShellGet {Install-Module, Find-Module, Save-Module, Update-Module...}
Script 1.2 PSReadline {Get-PSReadlineKeyHandler, Set-PSReadlineKeyHandler, Remove-PSReadlineKeyHandler, Get-PSReadl...
Script 1.11.1 PSScriptAnalyzer {Get-ScriptAnalyzerRule, Invoke-ScriptAnalyzer}
Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules
ModuleType Version Name ExportedCommands
Manifest 1.0.0.0 AppBackgroundTask {Disable-AppBackgroundTaskDiagnosticLog, Enable-AppBackgroundTaskDiagnosticLog, Set-AppBackgr...
Manifest 2.0.0.0 AppLocker {Get-AppLockerFileInformation, Get-AppLockerPolicy, New-AppLockerPolicy, Set-AppLockerPolicy...}
Manifest 1.0.0.0 AppvClient {Add-AppvClientConnectionGroup, Add-AppvClientPackage, Add-AppvPublishingServer, Disable-Appv...
Manifest 2.0.0.0 Appx {Add-AppxPackage, Get-AppxPackage, Get-AppxPackageManifest, Remove-AppxPackage...}
Script 1.0.0.0 AssignedAccess {Clear-AssignedAccess, Get-AssignedAccess, Set-AssignedAccess}
Manifest 1.0.0.0 BitLocker {Unlock-BitLocker, Suspend-BitLocker, Resume-BitLocker, Remove-BitLockerKeyProtector...}
Manifest 2.0.0.0 BitsTransfer {Add-BitsFile, Complete-BitsTransfer, Get-BitsTransfer, Remove-BitsTransfer...}
Manifest 1.0.0.0 BranchCache {Add-BCDataCacheExtension, Clear-BCCache, Disable-BC, Disable-BCDowngrading...}
Manifest 1.0.0.0 CimCmdlets {Get-CimAssociatedInstance, Get-CimClass, Get-CimInstance, Get-CimSession...}
Manifest 1.0 ConfigCI {Get-SystemDriver, New-CIPolicyRule, New-CIPolicy, Get-CIPolicy...}
Manifest 1.0 Defender {Get-MpPreference, Set-MpPreference, Add-MpPreference, Remove-MpPreference...}
Manifest 1.0.0.0 DirectAccessClientComponents {Disable-DAManualEntryPointSelection, Enable-DAManualEntryPointSelection, Get-DAClientExperie...
Script 3.0 Dism {Add-AppxProvisionedPackage, Add-WindowsDriver, Add-WindowsCapability, Add-WindowsImage...}
Manifest 1.0.0.0 DnsClient {Resolve-DnsName, Clear-DnsClientCache, Get-DnsClient, Get-DnsClientCache...}
Manifest 1.0.0.0 EventTracingManagement {New-EtwTraceSession, Get-EtwTraceSession, Set-EtwTraceSession, Send-EtwTraceSession...}
Manifest 1.0.0.0 HgsClient {Get-HgsAttestationBaselinePolicy, Get-HgsClientConfiguration, Set-HgsClientConfiguration, Ne...
Manifest 1.0.0.0 HgsDiagnostics {New-HgsTraceTarget, Get-HgsTrace, Get-HgsTraceFileData, Test-HgsTraceTarget}
Binary 2.0.0.0 Hyper-V {Add-VMAssignableDevice, Add-VMDvdDrive, Add-VMFibreChannelHba, Add-VMGpuPartitionAdapter...}
Binary 1.1 Hyper-V {Add-VMDvdDrive, Add-VMFibreChannelHba, Add-VMHardDiskDrive, Add-VMMigrationNetwork...}
Manifest 2.0.0.0 International {Get-WinDefaultInputMethodOverride, Set-WinDefaultInputMethodOverride, Get-WinHomeLocation, S...
Manifest 1.0.0.0 iSCSI {Get-IscsiTargetPortal, New-IscsiTargetPortal, Remove-IscsiTargetPortal, Update-IscsiTargetPo...
Script 1.0.0.0 ISE {New-IseSnippet, Import-IseSnippet, Get-IseSnippet}
Manifest 1.0.0.0 Kds {Add-KdsRootKey, Get-KdsRootKey, Test-KdsRootKey, Set-KdsConfiguration...}
Manifest 1.0.1.0 Microsoft.PowerShell.Archive {Compress-Archive, Expand-Archive}
Manifest 3.0.0.0 Microsoft.PowerShell.Diagnostics {Get-WinEvent, Get-Counter, Import-Counter, Export-Counter...}
Manifest 3.0.0.0 Microsoft.PowerShell.Host {Start-Transcript, Stop-Transcript}
Manifest 1.0.0.0 Microsoft.PowerShell.LocalAccounts {Add-LocalGroupMember, Disable-LocalUser, Enable-LocalUser, Get-LocalGroup...}
Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Content, Clear-Content, Clear-ItemProperty, Join-Path...}
Script 1.0 Microsoft.PowerShell.ODataUtils Export-ODataEndpointProxy
Manifest 3.0.0.0 Microsoft.PowerShell.Security {Get-Acl, Set-Acl, Get-PfxCertificate, Get-Credential...}
Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Format-List, Format-Custom, Format-Table, Format-Wide...}
Manifest 3.0.0.0 Microsoft.WSMan.Management {Disable-WSManCredSSP, Enable-WSManCredSSP, Get-WSManCredSSP, Set-WSManQuickConfig...}
Manifest 1.0 MMAgent {Disable-MMAgent, Enable-MMAgent, Set-MMAgent, Get-MMAgent...}
Manifest 1.0.0.0 MsDtc {New-DtcDiagnosticTransaction, Complete-DtcDiagnosticTransaction, Join-DtcDiagnosticResourceM...
Manifest 1.1.166.0 MSOnline {Get-MsolDevice, Remove-MsolDevice, Enable-MsolDevice, Disable-MsolDevice...}
Manifest 1.1.166.0 MSOnlineExtended {Get-MsolDevice, Remove-MsolDevice, Enable-MsolDevice, Disable-MsolDevice...}
Manifest 2.0.0.0 NetAdapter {Disable-NetAdapter, Disable-NetAdapterBinding, Disable-NetAdapterChecksumOffload, Disable-Ne...
Manifest 1.0.0.0 NetConnection {Get-NetConnectionProfile, Set-NetConnectionProfile}
Manifest 1.0.0.0 NetEventPacketCapture {New-NetEventSession, Remove-NetEventSession, Get-NetEventSession, Set-NetEventSession...}
Manifest 2.0.0.0 NetLbfo {Add-NetLbfoTeamMember, Add-NetLbfoTeamNic, Get-NetLbfoTeam, Get-NetLbfoTeamMember...}
Manifest 1.0.0.0 NetNat {Get-NetNat, Get-NetNatExternalAddress, Get-NetNatStaticMapping, Get-NetNatSession...}
Manifest 2.0.0.0 NetQos {Get-NetQosPolicy, Set-NetQosPolicy, Remove-NetQosPolicy, New-NetQosPolicy}
Manifest 2.0.0.0 NetSecurity {Get-DAPolicyChange, New-NetIPsecAuthProposal, New-NetIPsecMainModeCryptoProposal, New-NetIPs...
Manifest 1.0.0.0 NetSwitchTeam {New-NetSwitchTeam, Remove-NetSwitchTeam, Get-NetSwitchTeam, Rename-NetSwitchTeam...}
Manifest 1.0.0.0 NetTCPIP {Get-NetIPAddress, Get-NetIPInterface, Get-NetIPv4Protocol, Get-NetIPv6Protocol...}
Manifest 1.0.0.0 NetWNV {Get-NetVirtualizationProviderAddress, Get-NetVirtualizationGlobal, Get-NetVirtualizationLook...
Manifest 1.0.0.0 NetworkConnectivityStatus {Get-DAConnectionStatus, Get-NCSIPolicyConfiguration, Reset-NCSIPolicyConfiguration, Set-NCSI...
Manifest 1.0.0.0 NetworkSwitchManager {Disable-NetworkSwitchEthernetPort, Enable-NetworkSwitchEthernetPort, Get-NetworkSwitchEthern...
Manifest 1.0.0.0 NetworkTransition {Add-NetIPHttpsCertBinding, Disable-NetDnsTransitionConfiguration, Disable-NetIPHttpsProfile,...
Manifest 1.0.0.0 PcsvDevice {Get-PcsvDevice, Start-PcsvDevice, Stop-PcsvDevice, Restart-PcsvDevice...}
Manifest 1.0.0.0 PKI {Add-CertificateEnrollmentPolicyServer, Export-Certificate, Export-PfxCertificate, Get-Certif...
Manifest 1.0.0.0 PnpDevice {Get-PnpDevice, Get-PnpDeviceProperty, Enable-PnpDevice, Disable-PnpDevice}
Manifest 1.1 PrintManagement {Add-Printer, Add-PrinterDriver, Add-PrinterPort, Get-PrintConfiguration...}
Manifest 1.1 PSDesiredStateConfiguration {Set-DscLocalConfigurationManager, Start-DscConfiguration, Test-DscConfiguration, Publish-Dsc...
Script 1.0.0.0 PSDiagnostics {Disable-PSTrace, Disable-PSWSManCombinedTrace, Disable-WSManTrace, Enable-PSTrace...}
Binary 1.1.0.0 PSScheduledJob {New-JobTrigger, Add-JobTrigger, Remove-JobTrigger, Get-JobTrigger...}
Manifest 2.0.0.0 PSWorkflow {New-PSWorkflowExecutionOption, New-PSWorkflowSession, nwsn}
Manifest 1.0.0.0 PSWorkflowUtility Invoke-AsWorkflow
Manifest 1.0.0.0 ScheduledTasks {Get-ScheduledTask, Set-ScheduledTask, Register-ScheduledTask, Unregister-ScheduledTask...}
Manifest 2.0.0.0 SecureBoot {Confirm-SecureBootUEFI, Set-SecureBootUEFI, Get-SecureBootUEFI, Format-SecureBootUEFI...}
Manifest 2.0.0.0 SmbShare {Get-SmbShare, Remove-SmbShare, Set-SmbShare, Block-SmbShareAccess...}
Manifest 2.0.0.0 SmbWitness {Get-SmbWitnessClient, Move-SmbWitnessClient, gsmbw, msmbw...}
Manifest 1.0.0.0 StartLayout {Export-StartLayout, Import-StartLayout, Get-StartApps}
Manifest 2.0.0.0 Storage {Add-InitiatorIdToMaskingSet, Add-PartitionAccessPath, Add-PhysicalDisk, Add-TargetPortToMask...
Manifest 2.0.0.0 TLS {New-TlsSessionTicketKey, Enable-TlsSessionTicketKey, Disable-TlsSessionTicketKey, Export-Tls...
Manifest 1.0.0.0 TroubleshootingPack {Get-TroubleshootingPack, Invoke-TroubleshootingPack}
Manifest 2.0.0.0 TrustedPlatformModule {Get-Tpm, Initialize-Tpm, Clear-Tpm, Unblock-Tpm...}
Binary 2.1.639.0 UEV {Clear-UevConfiguration, Clear-UevAppxPackage, Restore-UevBackup, Set-UevTemplateProfile...}
Manifest 2.0.0.0 VpnClient {Add-VpnConnection, Set-VpnConnection, Remove-VpnConnection, Get-VpnConnection...}
Manifest 1.0.0.0 Wdac {Get-OdbcDriver, Set-OdbcDriver, Get-OdbcDsn, Add-OdbcDsn...}
Manifest 1.0.0.0 WindowsDeveloperLicense {Get-WindowsDeveloperLicense, Unregister-WindowsDeveloperLicense, Show-WindowsDeveloperLicens...
Script 1.0 WindowsErrorReporting {Enable-WindowsErrorReporting, Disable-WindowsErrorReporting, Get-WindowsErrorReporting}
Manifest 1.0.0.0 WindowsSearch {Get-WindowsSearchSetting, Set-WindowsSearchSetting}
Manifest 1.0.0.0 WindowsUpdate Get-WindowsUpdateLog

C:>

Marc013 avatar May 12 '17 17:05 Marc013

@Marc013 I don't see any problems there. I'm kind of baffled by the message, I can't reproduce this issue - are you using live id or org id credentials?

Can you repro with $DebugPreference="Continue" and send the debug log (for the login and the failure)

markcowl avatar May 12 '17 23:05 markcowl

@markcowl herewith the information you requested.

The Visual Studio subscription is linked to a Live ID however I do not use that ID to login to Azure. I have created an Azure AD account with owner access to the subscription that I use. The other account is also an Azure AD account which has access owner access to the CSP subscriptions owned by my employer.

I did not experience these issues with module AzureRM version 3.7.0.

C:\>  $DebugPreference="Continue"
C:\> Add-AzureRmAccount
DEBUG: 08:32:55 - AddAzureRMAccountCommand begin processing with ParameterSet 'UserWithSubscriptionId'.
DEBUG: [Common.Authentication]: Authenticating using configuration values: Domain: 'Common', Endpoint: 'https://login.microsoftonline.com/', ClientId:
'1950**************************************5fc2', ClientRedirect: 'urn:ietf:wg:oauth:2.0:oob', ResourceClientUri: 'https://management.core.windows.net/',
ValidateAuthrity: 'True'
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 05/13/2017 06:32:55:  - AuthenticationContext: ADAL .NET with assembly version '2.28.3.860', file version '2.28.31117.1411' and informational
version '78bd21073cfd91768d97894ace1ba90c5b904eec' is running...
DEBUG: [Common.Authentication]: Acquiring token using context with Authority 'https://login.microsoftonline.com/Common/', CorrelationId:
'00000000-0000-0000-0000-000000000000', ValidateAuthority: 'True'
DEBUG: [Common.Authentication]: Acquiring token using AdalConfiguration with Domain: 'Common', AdEndpoint: 'https://login.microsoftonline.com/', ClientId:
 '1950**************************************5fc2', ClientRedirectUri: urn:ietf:wg:oauth:2.0:oob
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 05/13/2017 06:32:55: d53b**************************************0c71d - AcquireTokenHandlerBase: === Token Acquisition started:
 Authority: https://login.microsoftonline.com/Common/
 Resource: https://management.core.windows.net/
 ClientId: 1950**************************************5fc2
 CacheType: Microsoft.Azure.Commands.Common.Authentication.AuthenticationStoreTokenCache (0 items)
 Authentication Target: User

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 05/13/2017 06:32:55:  - WindowsFormsWebAuthenticationDialogBase: Navigating to
'https://login.microsoftonline.com/Common/oauth2/authorize?resource=https://management.core.windows.net/&client_id=1950**************************************5fc2&re
sponse_type=code&haschrome=1&redirect_uri=urn:ietf:wg:oauth:2.0:oob&client-request-id=d53b**************************************0c71d&prompt=login&x-client-SKU=.NET&
x-client-Ver=2.28.3.860&x-client-CPU=x64&x-client-OS=Microsoft Windows NT 10.0.14393.0&site_id=501358&display=popup'.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 05/13/2017 06:32:55:  - WindowsFormsWebAuthenticationDialogBase: Navigated to
'https://login.microsoftonline.com/Common/oauth2/authorize?resource=https://management.core.windows.net/&client_id=1950**************************************5fc2&re
sponse_type=code&haschrome=1&redirect_uri=urn:ietf:wg:oauth:2.0:oob&client-request-id=d53b**************************************0c71d&prompt=login&x-client-SKU=.NET&
x-client-Ver=2.28.3.860&x-client-CPU=x64&x-client-OS=Microsoft Windows NT 10.0.14393.0&site_id=501358&display=popup'.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 05/13/2017 06:33:03:  - WindowsFormsWebAuthenticationDialogBase: Navigating to 'https://login.microsoftonline.com/common/login'.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 05/13/2017 06:33:03:  - WindowsFormsWebAuthenticationDialogBase: WebBrowser state: IsBusy: True, ReadyState: Complete, Created: True, Disposing:
False, IsDisposed: False, IsOffline: False
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 05/13/2017 06:33:03:  - WindowsFormsWebAuthenticationDialogBase: WebBrowser state (after Stop): IsBusy: False, ReadyState: Complete, Created: True,
 Disposing: False, IsDisposed: False, IsOffline: False
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 05/13/2017 06:33:03: d53b**************************************0c71d - TokenCache: Storing token in the cache...
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 05/13/2017 06:33:03: d53b**************************************0c71d - TokenCache: An item was stored in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 05/13/2017 06:33:03: d53b**************************************0c71d - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token
was retuned:
 Access Token Hash: gUEC*****************************************0Tg=
 Refresh Token Hash: guNP*****************************************rek=
 Expiration Time: 05/13/2017 07:33:02 +00:00
 User Hash: dp9N*****************************************jzs=

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 05/13/2017 06:33:03:  - TokenCache: Serializing token cache with 1 items.
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/tenants?api-version=2016-06-01

Headers:
x-ms-client-request-id        : 114d**************************************ca9f
accept-language               : en-US

Body:


DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Pragma                        : no-cache
x-ms-ratelimit-remaining-tenant-reads: 14999
x-ms-request-id               : b8ca**************************************8dd0
x-ms-correlation-request-id   : b8ca**************************************8dd0
x-ms-routing-request-id       : UKSOUTH:20170513T063306Z:b8ca**************************************8dd0
Strict-Transport-Security     : max-age=31536000; includeSubDomains
Cache-Control                 : no-cache
Date                          : Sat, 13 May 2017 06:33:05 GMT

Body:
{
  "value": [
    {
      "id": "/tenants/7dfb************************************1bbf2",
      "tenantId": "7dfb************************************1bbf2"
    }
  ]
}

DEBUG: [Common.Authentication]: Authenticating using configuration values: Domain: '7dfb************************************1bbf2', Endpoint:
'https://login.microsoftonline.com/', ClientId: '1950**************************************5fc2', ClientRedirect: 'urn:ietf:wg:oauth:2.0:oob', ResourceClientUri:
'https://management.core.windows.net/', ValidateAuthrity: 'True'
DEBUG: [Common.Authentication]: Acquiring token using context with Authority 'https://login.microsoftonline.com/7dfb************************************1bbf2/',
CorrelationId: '00000000-0000-0000-0000-000000000000', ValidateAuthority: 'True'
DEBUG: [Common.Authentication]: Acquiring token using AdalConfiguration with Domain: '7dfb************************************1bbf2', AdEndpoint:
'https://login.microsoftonline.com/', ClientId: '1950**************************************5fc2', ClientRedirectUri: urn:ietf:wg:oauth:2.0:oob
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 05/13/2017 06:33:04: 5734**************************************b1b1 - AcquireTokenHandlerBase: === Token Acquisition started:
 Authority: https://login.microsoftonline.com/7dfb************************************1bbf2/
 Resource: https://management.core.windows.net/
 ClientId: 1950**************************************5fc2
 CacheType: Microsoft.Azure.Commands.Common.Authentication.AuthenticationStoreTokenCache (1 items)
 Authentication Target: User

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 05/13/2017 06:33:04: 5734**************************************b1b1 - TokenCache: Looking up cache for a token...
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 05/13/2017 06:33:04: 5734**************************************b1b1 - TokenCache: An item matching the requested resource was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 05/13/2017 06:33:04: 5734**************************************b1b1 - TokenCache: 59.967969635 minutes left until token in cache expires
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 05/13/2017 06:33:04: 5734**************************************b1b1 - TokenCache: A matching item (access token or refresh token or both) was found in the
cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 05/13/2017 06:33:04: 5734**************************************b1b1 - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token
was retuned:
 Access Token Hash: gUEC*****************************************0Tg=
 Refresh Token Hash: guNP*****************************************rek=
 Expiration Time: 05/13/2017 07:33:02 +00:00
 User Hash: dp9N*****************************************jzs=

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 05/13/2017 06:33:04:  - TokenCache: Serializing token cache with 1 items.
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/subscriptions?api-version=2016-06-01

Headers:
x-ms-client-request-id        : 597b**************************************2200
accept-language               : en-US

Body:


DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Pragma                        : no-cache
x-ms-ratelimit-remaining-tenant-reads: 14999
x-ms-request-id               : 74ab**************************************e237
x-ms-correlation-request-id   : 74ab**************************************e237
x-ms-routing-request-id       : UKSOUTH:20170513T063307Z:74ab**************************************e237
Strict-Transport-Security     : max-age=31536000; includeSubDomains
Cache-Control                 : no-cache
Date                          : Sat, 13 May 2017 06:33:06 GMT

Body:
{
  "value": [
    {
      "id": "/subscriptions/bc69************************************b1e5",
      "subscriptionId": "bc69************************************b1e5",
      "displayName": "Visual Studio Enterprise",
      "state": "Enabled",
      "subscriptionPolicies": {
        "locationPlacementId": "Public_2014-09-01",
        "quotaId": "MSDN_2014-09-01",
        "spendingLimit": "On"
      },
      "authorizationSource": "RoleBased"
    }
  ]
}



Environment           : AzureCloud
Account               : MarcTest@********.onmicrosoft.com
TenantId              : 7dfb************************************1bbf2
SubscriptionId        : bc69************************************b1e5
SubscriptionName      : Visual Studio Enterprise
CurrentStorageAccount :

DEBUG: 08:33:05 - AddAzureRMAccountCommand end processing.
DEBUG: 08:33:05 - AddAzureRMAccountCommand end processing.


C:\> Save-AzureRmContext -Path "C:\Temp\Marc1.json"
DEBUG: 08:33:40 - SaveAzureRMContextCommand begin processing with ParameterSet '__AllParameterSets'.
DEBUG: 08:33:40 - using account id 'MarcTest@********.onmicrosoft.com'...
DEBUG: 08:33:40 - SaveAzureRMContextCommand end processing.
DEBUG: 08:33:40 - SaveAzureRMContextCommand end processing.
C:\> Add-AzureRmAccount
DEBUG: 08:33:50 - AddAzureRMAccountCommand begin processing with ParameterSet 'UserWithSubscriptionId'.
DEBUG: [Common.Authentication]: Authenticating using configuration values: Domain: 'Common', Endpoint: 'https://login.microsoftonline.com/', ClientId:
'1950**************************************5fc2', ClientRedirect: 'urn:ietf:wg:oauth:2.0:oob', ResourceClientUri: 'https://management.core.windows.net/',
ValidateAuthrity: 'True'
DEBUG: [Common.Authentication]: Acquiring token using context with Authority 'https://login.microsoftonline.com/Common/', CorrelationId:
'00000000-0000-0000-0000-000000000000', ValidateAuthority: 'True'
DEBUG: [Common.Authentication]: Acquiring token using AdalConfiguration with Domain: 'Common', AdEndpoint: 'https://login.microsoftonline.com/', ClientId:
 '1950**************************************5fc2', ClientRedirectUri: urn:ietf:wg:oauth:2.0:oob
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 05/13/2017 06:33:50: c166**************************************2553 - AcquireTokenHandlerBase: === Token Acquisition started:
 Authority: https://login.microsoftonline.com/Common/
 Resource: https://management.core.windows.net/
 ClientId: 1950**************************************5fc2
 CacheType: Microsoft.Azure.Commands.Common.Authentication.AuthenticationStoreTokenCache (1 items)
 Authentication Target: User

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 05/13/2017 06:33:50:  - WindowsFormsWebAuthenticationDialogBase: Navigating to
'https://login.microsoftonline.com/Common/oauth2/authorize?resource=https://management.core.windows.net/&client_id=1950**************************************5fc2&re
sponse_type=code&haschrome=1&redirect_uri=urn:ietf:wg:oauth:2.0:oob&client-request-id=c166**************************************2553&prompt=login&x-client-SKU=.NET&
x-client-Ver=2.28.3.860&x-client-CPU=x64&x-client-OS=Microsoft Windows NT 10.0.14393.0&site_id=501358&display=popup'.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 05/13/2017 06:33:51:  - WindowsFormsWebAuthenticationDialogBase: Navigated to
'https://login.microsoftonline.com/Common/oauth2/authorize?resource=https://management.core.windows.net/&client_id=1950**************************************5fc2&re
sponse_type=code&haschrome=1&redirect_uri=urn:ietf:wg:oauth:2.0:oob&client-request-id=c166**************************************2553&prompt=login&x-client-SKU=.NET&
x-client-Ver=2.28.3.860&x-client-CPU=x64&x-client-OS=Microsoft Windows NT 10.0.14393.0&site_id=501358&display=popup'.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 05/13/2017 06:34:04:  - WindowsFormsWebAuthenticationDialogBase: Navigating to 'https://login.microsoftonline.com/common/login'.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 05/13/2017 06:34:04:  - WindowsFormsWebAuthenticationDialogBase: WebBrowser state: IsBusy: True, ReadyState: Complete, Created: True, Disposing:
False, IsDisposed: False, IsOffline: False
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 05/13/2017 06:34:04:  - WindowsFormsWebAuthenticationDialogBase: WebBrowser state (after Stop): IsBusy: False, ReadyState: Complete, Created: True,
 Disposing: False, IsDisposed: False, IsOffline: False
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 05/13/2017 06:34:04: c166**************************************2553 - TokenCache: Storing token in the cache...
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 05/13/2017 06:34:04: c166**************************************2553 - TokenCache: An item was stored in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 05/13/2017 06:34:04: c166**************************************2553 - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token
was retuned:
 Access Token Hash: bZdY**************************************O79k=
 Refresh Token Hash: VYA7**************************************6es=
 Expiration Time: 05/13/2017 07:34:03 +00:00
 User Hash: SA5u**************************************xlc=

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 05/13/2017 06:34:04:  - TokenCache: Serializing token cache with 2 items.
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/tenants?api-version=2016-06-01

Headers:
x-ms-client-request-id        : 3a39**************************************823c
accept-language               : en-US

Body:


DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Pragma                        : no-cache
x-ms-ratelimit-remaining-tenant-reads: 14999
x-ms-request-id               : 123e**************************************83cc
x-ms-correlation-request-id   : 123e**************************************83cc
x-ms-routing-request-id       : UKSOUTH:20170513T063407Z:123e**************************************83cc
Strict-Transport-Security     : max-age=31536000; includeSubDomains
Cache-Control                 : no-cache
Date                          : Sat, 13 May 2017 06:34:07 GMT

Body:
{
  "value": [
    {
      "id": "/tenants/62c6***************************************1dc0",
      "tenantId": "62c6***************************************1dc0"
    }
  ]
}

DEBUG: [Common.Authentication]: Authenticating using configuration values: Domain: '62c6***************************************1dc0', Endpoint:
'https://login.microsoftonline.com/', ClientId: '1950**************************************5fc2', ClientRedirect: 'urn:ietf:wg:oauth:2.0:oob', ResourceClientUri:
'https://management.core.windows.net/', ValidateAuthrity: 'True'
DEBUG: [Common.Authentication]: Acquiring token using context with Authority 'https://login.microsoftonline.com/62c6***************************************1dc0/',
CorrelationId: '00000000-0000-0000-0000-000000000000', ValidateAuthority: 'True'
DEBUG: [Common.Authentication]: Acquiring token using AdalConfiguration with Domain: '62c6***************************************1dc0', AdEndpoint:
'https://login.microsoftonline.com/', ClientId: '1950**************************************5fc2', ClientRedirectUri: urn:ietf:wg:oauth:2.0:oob
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 05/13/2017 06:34:05: 3ee6**************************************5d8b - AcquireTokenHandlerBase: === Token Acquisition started:
 Authority: https://login.microsoftonline.com/62c6***************************************1dc0/
 Resource: https://management.core.windows.net/
 ClientId: 1950**************************************5fc2
 CacheType: Microsoft.Azure.Commands.Common.Authentication.AuthenticationStoreTokenCache (2 items)
 Authentication Target: User

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 05/13/2017 06:34:05: 3ee6**************************************5d8b - TokenCache: Looking up cache for a token...
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 05/13/2017 06:34:05: 3ee6**************************************5d8b - TokenCache: An item matching the requested resource was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 05/13/2017 06:34:05: 3ee6**************************************5d8b - TokenCache: 59.9734478633333 minutes left until token in cache expires
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 05/13/2017 06:34:05: 3ee6**************************************5d8b - TokenCache: A matching item (access token or refresh token or both) was found in the
cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 05/13/2017 06:34:05: 3ee6**************************************5d8b - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token
was retuned:
 Access Token Hash: bZdY**************************************O79k=
 Refresh Token Hash: VYA7**************************************6es=
 Expiration Time: 05/13/2017 07:34:03 +00:00
 User Hash: SA5u**************************************xlc=

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 05/13/2017 06:34:05:  - TokenCache: Serializing token cache with 2 items.
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/subscriptions?api-version=2016-06-01

Headers:
x-ms-client-request-id        : c00a**************************************2a6e
accept-language               : en-US

Body:


DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Pragma                        : no-cache
x-ms-ratelimit-remaining-tenant-reads: 14999
x-ms-request-id               : 8e4c**************************************b987
x-ms-correlation-request-id   : 8e4c**************************************b987
x-ms-routing-request-id       : UKSOUTH:20170513T063407Z:8e4c**************************************b987
Strict-Transport-Security     : max-age=31536000; includeSubDomains
Cache-Control                 : no-cache
Date                          : Sat, 13 May 2017 06:34:07 GMT

Body:
{
  "value": [
    {
      "id": "/subscriptions/692b***************************************c8b3",
      "subscriptionId": "692b***************************************c8b3",
      "displayName": "A*********************************** Development1",
      "state": "Enabled",
      "subscriptionPolicies": {
        "locationPlacementId": "Public_2014-09-01",
        "quotaId": "CSP_2015-05-01",
        "spendingLimit": "Off"
      },
      "authorizationSource": "RoleBased"
    },
    {
      "id": "/subscriptions/dfad**************************************5817",
      "subscriptionId": "dfad**************************************5817",
      "displayName": "A*********************************** Development2",
      "state": "Enabled",
      "subscriptionPolicies": {
        "locationPlacementId": "Public_2014-09-01",
        "quotaId": "CSP_2015-05-01",
        "spendingLimit": "Off"
      },
      "authorizationSource": "RoleBased"
    }
  ]
}



Environment           : AzureCloud
Account               : anl2****@****oud.eu
TenantId              : 62c6***************************************1dc0
SubscriptionId        : 692b***************************************c8b3
SubscriptionName      : A*********************************** Development1
CurrentStorageAccount :

DEBUG: 08:34:06 - AddAzureRMAccountCommand end processing.
DEBUG: 08:34:06 - AddAzureRMAccountCommand end processing.


C:\> Save-AzureRmContext -Path "C:\Temp\Marc2.json"
DEBUG: 08:34:14 - SaveAzureRMContextCommand begin processing with ParameterSet '__AllParameterSets'.
DEBUG: 08:34:14 - using account id 'anl2****@****oud.eu'...
DEBUG: 08:34:14 - SaveAzureRMContextCommand end processing.
DEBUG: 08:34:14 - SaveAzureRMContextCommand end processing.
C:\> Import-AzureRmContext -Path "C:\Temp\Marc1.json"


Environment           : AzureCloud
Account               : MarcTest@********.onmicrosoft.com
TenantId              : 7dfb************************************1bbf2
SubscriptionId        : bc69************************************b1e5
SubscriptionName      : Visual Studio Enterprise
CurrentStorageAccount :

DEBUG: 08:34:21 - ImportAzureRMContextCommand end processing.
DEBUG: 08:34:21 - ImportAzureRMContextCommand end processing.


C:\> Get-AzureRmResourceGroup
DEBUG: 08:34:27 - GetAzureResourceGroupCmdlet begin processing with ParameterSet 'Lists the resource group based on the name.'.
DEBUG: 08:34:27 - using account id 'MarcTest@********.onmicrosoft.com'...
DEBUG: [Common.Authentication]: Authenticating using Account: 'MarcTest@********.onmicrosoft.com', environment: 'AzureCloud', tenant:
'7dfb************************************1bbf2'
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 05/13/2017 06:34:27: f147**************************************3ceb - AcquireTokenHandlerBase: === Token Acquisition started:
 Authority: https://login.microsoftonline.com/7dfb************************************1bbf2/
 Resource: https://management.core.windows.net/
 ClientId: 1950**************************************5fc2
 CacheType: Microsoft.Azure.Commands.Common.Authentication.AuthenticationStoreTokenCache (0 items)
 Authentication Target: User

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 05/13/2017 06:34:27: f147**************************************3ceb - TokenCache: Looking up cache for a token...
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 05/13/2017 06:34:27: f147**************************************3ceb - TokenCache: No matching token was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 05/13/2017 06:34:27: f147**************************************3ceb - AcquireTokenSilentHandler: No token matching arguments found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Error: 4 :
DEBUG: 05/13/2017 06:34:27: f147**************************************3ceb - <RunAsync>d__0:
Microsoft.IdentityModel.Clients.ActiveDirectory.AdalSilentTokenAcquisitionException: Failed to acquire token silently. Call method AcquireToken
   at Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenSilentHandler.SendTokenRequestAsync()
   at Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenHandlerBase.<RunAsync>d__0.MoveNext()
 ErrorCode: failed_to_acquire_token_silently
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 05/13/2017 06:34:27:  - TokenCache: Serializing token cache with 0 items.
DEBUG: [Common.Authentication]: Received exception Authentication error while acquiring token: 'Failed to acquire token silently. Call method
AcquireToken'., while authenticating.
Get-AzureRmResourceGroup : Your Azure credentials have not been set up or have expired, please run Login-AzureRMAccount to set up your Azure credentials.
At line:1 char:1
+ Get-AzureRmResourceGroup
+ ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Get-AzureRmResourceGroup], ArgumentException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.GetAzureResourceGroupCmdlet

DEBUG: 08:34:27 - GetAzureResourceGroupCmdlet end processing.
DEBUG: 08:34:27 - GetAzureResourceGroupCmdlet end processing.
C:\>

Marc013 avatar May 13 '17 09:05 Marc013

@markcowl Update.

As you mentioned you can not reproduce my reported issue I installed the latest version of PowerShell module, Azure (4.0.1), AzureRM (4.0.1), and AzureAD (2.0.0.115) on a vanilla virtualized Windows Server 2016 server I installed, and patched, yesterday (May 12 2017). I executed the following actions:

action result comment
Connect to Visual Studion Enterprise (MSDN) tenant using 'onmicrosoft.com' Azure AD account Successful
Save the AzureRM context Marc1.json Successful
Connect to my employers (CSP) tenant using an Azure AD account which has an UPN conform the adjusted default Azure AD domain name Successful
Save the AzureRM context Marc2.json Successful
Import AzureRM context Marc1.json Successful MSDN tenant & subscription
Run cmdlet Get-AzureRmResourceGroup Failed with the reported error message
Run cmdlet Get-AzureRmResource Failed with the reported error message
Run cmdlet Get-AzureRmAutomationAccount Failed with the reported error message
Import AzureRM context Marc2.json Successful CSP tenant & subscriptions
Run cmdlet Get-AzureRmResourceGroup Failed with the reported error message
Run cmdlet Get-AzureRmResource Successful
Run cmdlet Get-AzureRmAutomationAccount Successful

When I performed these same actions on my Windows 10 system which has the previous PowerShell module version, Azure (4.0.0), AzureRM (4.0.0), and AzureAD (2.0.0.115), all tests failed with the reported error message.

Get-AzureRmAutomationAccount : Your Azure credentials have not been set up or have expired, please run Login-AzureRMAccount to set up your Azure credentia
ls.
At line:1 char:1
+ Get-AzureRmAutomationAccount
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Get-AzureRmAutomationAccount], ArgumentException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Automation.Cmdlet.GetAzureAutomationAccount

I then removed the Azure modules on my Windows 10 system

Get-Module -ListAvailable -Name Azure* | Uninstall-Module

Installed the lastest version, Azure (4.0.1), AzureRM (4.0.1), and AzureAD (2.0.0.115) I then did the exact same actions/tests which gave the same results as on the Windows Server 2016 system. So with version 4.0.0 I get an error message no mather which cmdlet or tenant is use.

With version 4.0.1 I get an error message on all cmdlets I use when connected to the MSDN tenant. When connected to the CSP tenant I only get an error on cmdlet Get-AzureRmResourceGroup.

Marc013 avatar May 13 '17 10:05 Marc013

I can confirm that I'm also having this issue. However, it only occurs with a certain organizational login. My other two Azure logins (one MS account and one Org) both work fine.

webbdog28 avatar May 19 '17 19:05 webbdog28

@Marc013 @webbdog28 I missed the AzureAD module previously in your comments - there may be some interaction there with the token cache. In any of these instances did you use the AzureAD module in the same session?

markcowl avatar May 21 '17 19:05 markcowl

@markcowl When encountering the reported issue the AzureAD module is not imported. However I do have runbooks that do load the Azure, AzureRM and AzureAD module. In that situation the cmdlets are to work as they are intended to, not?

To reproduce the reported issue I performed the described steps in my previous comment, noting more, nothing less. I don't keep any secrets ;-) It's way to important for me to get this issue solved as soon as possible!

Marc013 avatar May 22 '17 05:05 Marc013

Also able to repo this consistently... I have 4.0.1 installed from the Powershell Gallery AzureRM meta.

No longer able to run the majority of my scripts with automated login as the very first thing I generally do is Get-AzureRmResourceGroup which fails.

iamGavinJ avatar May 22 '17 11:05 iamGavinJ

I am also having problems with using Save-AzureRmContext and Import-AzureRmContext in version 3.0.0 of the AzureRm.profile module. With version 2.8.0 I was able to use Import-AzureRmContext in a background job but with 3.0.0 it throws this error: Your Azure credentials have not been set up or have expired, please run Login-AzureRMAccount to set up your Azure credentials.

To reproduce the problem I wrote the attached script: Issue3954.zip

The script supports two parameter sets:

-------------------------- EXAMPLE 1 --------------------------
PS C:\>.\Issue3954.ps1 -SubscriptionId "########-####-####-####-############"

-------------------------- EXAMPLE 2 --------------------------
PS C:\>.\Issue3954.ps1 -SubscriptionId "########-####-####-####-############" `
        -Tenant "########-####-####-####-############" `
        -ApplicationId "########-####-####-####-############" `
        -CertificateThumbprint "########################################"

Use the first parameter set (SubscriptionId parameter only) to sign in with interactive credentials. Use the second parameter set to specify the certificate and automation account.

If I sign into Azure interactively using my on-premises AD credentials (federated with AzureAD) then I receive the error. If I instead sign in with a certificate that is associated with an Azure Automation account, then I am able to workaround the problem.

SiloReed avatar May 23 '17 16:05 SiloReed

I was also having issues in PS v5.1 with Import-AzureRMContext child operations reporting "Your Azure credentials have not been set up or have expired"

I have resolved this by setting the context to include the subscription ID...

Import-AzureRmContext -Path $path Set-AzureRmContext -SubscriptionId xxx-xxx-xxx-xxx

Digiroka avatar May 24 '17 12:05 Digiroka

Digiroka's workaround does not work in a background job. I updated the scriptblock in my Issue3954.ps1 script to include Set-AzureRmContext:

$sb = {
    Import-AzureRmContext -AzureContext $using:AzureProfile
    Set-AzureRmContext -SubscriptionId $using:SubscriptionId
    Get-AzureRmResourceGroup | Select-Object ResourceGroupName
}

I was rewarded with an additional error message: Provided subscription ########-####-####-####-############ does not exist

SiloReed avatar May 26 '17 17:05 SiloReed

Yes I had exactly the same issue in the second attempt - it appears that I needed to reauthenticate and save the .ctx file again, then it worked. I assume that the token timed out. Imagine I will need to reauthenticate and save .ctx next time I try. Not great.

Digiroka avatar May 26 '17 19:05 Digiroka

I can confirm that I am also seeing the reported issue regarding Import-AzureRmContext and then calling Get-AzureRmResourceGroup after that. Error I get is: "Your Azure credentials have not been set up or have expired, please run Login-AzureRMAccount to set up your Azure credentials." The version giving me the above error is 4.0.1 which I installed on the 31st of May 2017. Before this I was on an older version of 3.0.0 where the old methods Save-AzureRmProfile and Select-AzureRmProfile were still present.

I also tried the workaround regarding Set-AzureRmContext, but just like @SiloReed I then get a different error: Provided subscription ########-####-####-####-############ does not exist

hermot avatar Jun 01 '17 05:06 hermot

+1, after updating to AzureRM.Profile 3.0.0 (AzureRM 4.0.0) this problem appeared. also, for me this only happens when using the user login, scripts using service principal are working fine

4c74356b41 avatar Jun 02 '17 07:06 4c74356b41

+1 repros for me. Have side-by-side installations of AzureRM (3.8.0 and 4.0.2) which installed AzureRM.profile versions (2.8.0 and 3.0.1). Under such conditions, getting the following error

Your Azure credentials have not been set up or have expired, please run Login-AzureRMAccount to set up your Azure credentials. + CategoryInfo : CloseError: (:) [New-AzureRmResourceGroup], ArgumentException + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupCmdlet + PSComputerName : localhost

Installed profile modules are...

Script 3.0.1 AzureRM.profile {Disable-AzureRmDataCollection, Enable-AzureRmDataCollection, Remove-AzureRmEnvironm... Script 2.8.0 AzureRM.profile {Disable-AzureRmDataCollection, Enable-AzureRmDataCollection, Remove-AzureRmEnvironm...

consultguru avatar Jun 02 '17 07:06 consultguru

The same here. Workaround helped

pogarek avatar Jun 03 '17 19:06 pogarek

I am getting the same problem, the workaround only helps if the following was executed prior to calling Import-AzureRmContext

Login-AzureRmAccount -Credential $xxx -ServicePrincipal -TenantId xxx

This defeats the purpose of caching the authentication in the first place

Effectively Import-AzureRmContext does not work.

Reproduction Steps

  1. Login-AzureRmAccount -Credential $xxx -ServicePrincipal -TenantId xxx on Machine A
  2. Save-AzureRmContext -Path $path -Force on Machine A
  3. Import-AzureRmContext -Path $path on Machine B
  4. Set-AzureRmContext -SubscriptionId xxx-xxx-xxx-xxx Machine B

ashley7070 avatar Jun 07 '17 05:06 ashley7070