Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import-AzureRmContext unable to use #3954

Closed
kuomingwu opened this issue May 12, 2017 · 55 comments
Closed

Import-AzureRmContext unable to use #3954

kuomingwu opened this issue May 12, 2017 · 55 comments
Assignees
Milestone

Comments

@kuomingwu
Copy link

kuomingwu commented May 12, 2017

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.

@Marc013
Copy link

Marc013 commented May 12, 2017

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 : 7df
bbf2
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 : 62c
1dc0
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 : 7df
bbf2
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>

@markcowl
Copy link
Member

markcowl commented May 12, 2017

@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
Copy link
Member

markcowl commented May 12, 2017

@kuomingwu Yes, the unfortunate obsolete warning is a known issue: #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?

@Marc013
Copy link

Marc013 commented May 12, 2017

@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:>

@markcowl
Copy link
Member

@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)

@Marc013
Copy link

Marc013 commented May 13, 2017

@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
Copy link

Marc013 commented May 13, 2017

@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.

@webbdog28
Copy link

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.

@markcowl
Copy link
Member

@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 markcowl added this to the June 2017 milestone May 21, 2017
@Marc013
Copy link

Marc013 commented May 22, 2017

@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!

@iamGavinJ
Copy link
Member

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.

@SiloReed
Copy link

SiloReed commented May 23, 2017

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.

@Digiroka
Copy link

Digiroka commented May 24, 2017

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

@SiloReed
Copy link

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

@Digiroka
Copy link

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.

@hermot
Copy link

hermot commented Jun 1, 2017

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

@4c74356b41
Copy link

4c74356b41 commented Jun 2, 2017

+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

@consultguru
Copy link

+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...

@pogarek
Copy link

pogarek commented Jun 3, 2017

The same here. Workaround helped

@ashley7070
Copy link

ashley7070 commented Jun 7, 2017

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

@pixelicous
Copy link

Same issue here, i have 2.6.0 and 3.0.1 installed - no issued before with import-azurermprofile.

@KacperMucha
Copy link

KacperMucha commented Jun 12, 2017

+1 I'm experiencing the same issue on many computers.
Update: Version 4.1.0 released 4 days ago also doesn't solve the problem.

@markcowl
Copy link
Member

@ashley7070 Moving the context from one machine to another is an explicit non-goal of this cmdlet.

@markcowl markcowl added this to the July 2017 milestone Jun 12, 2017
@4c74356b41
Copy link

@ashley7070 it is pretty clear you dont understand the difference between sharing session and being able to parallel out workloads. first is bad, second is good.

@guillemsola
Copy link

@4c74356b41 @pixelicous agree. I'm currently doing some performance testing where I need to start/stop up to 100 VM so I have many other interesting things to do than waiting one after the other 😄

@pixelicous
Copy link

@guillemsola Azure is sooo slow as is.. imagine without that cmdlet! They need to add -nowait to every cmdlet that handles resources, that annoying wait for a cmdlet to finish although you dont need to wait for it to finish is killing me, especially for runbooks where you pay by the minute and the provider of the resource is doing all the work, while your runbook does nothing but wait

@4c74356b41
Copy link

@pixelicous @guillemsola there will be -asjob switch soon, as far as i'm aware (there was an issue on this project, you can try searching for it). also, try using the Azure CLI v2 (the az one, not azure). it has got --no-wait on many calls

@pixelicous
Copy link

@4c74356b41 CLI won't do, i am working with powershell as i am using the scripts as runbooks. I have been trying to look for a thread such as this on GIT, wasn't sure where to start, i wrote on the MSDN forums about this today...
Are there any plans for the -asjob to work also with azure automation runbooks?? Right now i have to start automation jobs, meaning the scripts running on premise or running on the azure automation account have to be different (start-job / start-azurermautomationjob)

@4c74356b41
Copy link

@pixelicous I don't understand the question. no one forbids you starting 2 runbooks, or 20, or 20000. whats the problem? i mean, i mostly don't understand what you are asking.

@pixelicous
Copy link

@4c74356b41 Yes of course, but if i want the runbook to run for the least amount of minutes, as we pay by the minute. I want the runbook to continue on, without waiting for the action to complete, as i do not rely on its output, i want to fire and forget.. thus runbook will run much faster. hope i made it a bit more understandable :)

@4c74356b41
Copy link

@pixelicous oh, well, i don't know about that. I never tried jobs inside runbooks. if that works, I don't see a reason why not if not (which might be the case) you are out of luck

@pixelicous
Copy link

pixelicous commented Jun 14, 2017

@4c74356b41 i also dont work with jobs inside runbooks, according to my check it isn't supported, but i did need to translate my scripts to runbooks as i wanted the azure api functionality to execute runbooks.. so in order to bypass parallel processing issues (without using powershell workflow) i execute child runbooks without waiting for them (as seperate job).. thus was wondering if that -asjob function would work also on the azure, again - aiming for low runbook execution time as those running minutes cost $.. not a lot.. but still if you start to execute many of these, it can pile up

@SwapnilGoad
Copy link

SwapnilGoad commented Jun 16, 2017

Here's what I did to make it work for me:
Installed AzureRM version 3.8.0 on top of version 4.1.0:

Install-Module -Name AzureRM -RequiredVersion 3.8.0

Into the Script I explicitly imported version 3.8.0

Here's the sample script:

Import-Module AzureRM -RequiredVersion 3.8.0
$AzureProfilePath= "c:\ProfileContext.ctx"
Try{
       If(Test-Path $AzureProfilePath){
           #We have the credentials saved; Load Saved Credentials
           Import-AzureRmContext  -Path $AzureProfilePath
       }
       else{
          #We have not yet saved the credentials; Display the Login Window
          Login-AzureRmAccount
          Save-AzureRmContext -Path $AzureProfilePath -Force
       }
 }
catch{
       #Oop's something went wrong: 
        Write-Host $Error   
}

Get-AzureRmresourceGroup
Get-AzureRmResource

I have tested this with two different subscriptions and it works like charm............

@Marc013
Copy link

Marc013 commented Jun 16, 2017

@SwapnilGoad
With all due respect. What you are telling is not a solution. It's simply using an old version.

@markcowl
It's awfully quiet from your side.
Are you still working on a solution?

Currently, we can still make it work with loading the old PowerShell modules however we need to transfer to the latest version at latest 13th July 2017 as that is the date all Azure scheduled runbooks will be using the latest PowerShell modules!

@4c74356b41
Copy link

@Marc013 lol, i didn't even think about that, yeah, that sounds like a real blocker.

@markcowl
Copy link
Member

markcowl commented Jun 17, 2017

@Marc013 @kuomingwu @webbdog28 @iamGavinJ @SiloReed Found the root cause. The reason we had such a difficult time reproing was because we were stupidly not using a clean install on a new machine. Once we did this, it is easy to repro.

What is happening is that

(1) If you do not have TokenCache.dat in '%AppData%\Roaming\Windows Azure PowerShell' then you end up using a different TokenCache type
(2) When using this cache type, the TokenCache data serialized to the saved context file is not loaded into the cache properly

Have filed two issues to fix, slated for the July release (7/7). Meanwhile, will work on a workaround for you in the interim.

@markcowl
Copy link
Member

Issues: #4144, #4145

@markcowl
Copy link
Member

markcowl commented Jun 17, 2017

For those hitting this issue, here is a workaround:

$ctx = Import-AzureRmContext -Path <path-to-saved-context>
$session = [Microsoft.Azure.Commands.Common.Authentication.AzureSession]::Instance
$cacheFile = [System.IO.Path]::Combine($session.ProfileDirectory, $session.TokenCacheFile)
if (Test-Path $cacheFile) {
  $session.DataStore.CopyFile($cacheFile, ($cacheFile + ".bak"))
}
$session.DataStore.WriteFile( $cacheFile, [System.Security.Cryptography.ProtectedData]::Protect($ctx.Context.TokenCache.CacheData, $null, [System.Security.Cryptography.DataProtectionScope]::CurrentUser))
$session.TokenCache = New-Object -TypeName Microsoft.Azure.Commands.Common.Authentication.ProtectedFileTokenCache -ArgumentList $cacheFile
[Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile.DefaultContext.TokenCache = $session.TokenCache

@markcowl
Copy link
Member

markcowl commented Jun 17, 2017

Actually, here is a simpler workaround:

$ctx = Import-AzureRmContext -Path <path-to-saved-context>
$ctx.Context.TokenCache.Deserialize($ctx.Context.TokenCache.CacheData)

@markcowl
Copy link
Member

The first may fix the issue permanently on a machine. The second would need to be run each time you imported the context

@Marc013
Copy link

Marc013 commented Jun 17, 2017

@markcowl
Thanks! It's good to have a workaround (I tested it and it does the trick for me) and a date the permanent fix might be present.
Keeping my fingers crossed for the 7th of July ;-)

@markcowl
Copy link
Member

Fix shipped

@cormacpayne
Copy link
Member

This fix can be found in version 4.2.0 of Azure PowerShell

@testflyjets
Copy link

@markcowl It doesn't appear that these fixes have been applied to PowerShell v6.0.0-beta7 for Linux or Mac OS:

$ Import-AzureRmContext -Path $path
Import-AzureRmContext : Exception has been thrown by the target of an invocation.
At line:1 char:1
+ Import-AzureRmContext -Path $path
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Import-AzureRmContext], TargetInvocationException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.ImportAzureRMContextCommand

Any thoughts on this?

@v-sirebb
Copy link

Hi @markcowl , I tried with Azure powershell 5.1.1, but still seeing same problem. I saved context in machine A and trying to import it in machine B. Is this scenario supported?

@markcowl
Copy link
Member

@v-sirebb Please open a new issue rather than commenting on closed issues. It is not supported to move a context from one machine to another.

@pixelicous
Copy link

@markcowl i think that since your fix you broke some other thing

All of the sudden my scripts started throwing errors that are related to my profile timing out.
I save my profile then reuse it on the same machine in a job, not sure what is the trigger, where it is time, the way i use or maybe the number of times used, but all the scripts crash.. i wish i had the exact wording in the error, but it was just basically telling me the profile i have saved is no longer valid

I will reproduce and open a new issue

@pixelicous
Copy link

@v-sirebb @markcowl was a new ticket opened on this??

This issue still exists #7110 #7456

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests