-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Comments
Regarding version 4.0.0 Cmdlet 'Import-AzureRmContext' does not have an alias, neither is this cmdlet functional. ==== NO ALIAS ======================================================== C:\Temp> Get-Alias -Definition Import-AzureRmContext
==== NOT FUNCTIONAL ================================================== C:\Temp> Add-AzureRmAccount Environment : AzureCloud C:\Temp> Save-AzureRmContext -Path "C:\Temp\Marc1.json" Environment : AzureCloud C:\Temp> Save-AzureRmContext -Path "C:\Temp\Marc2.json" Environment : AzureCloud C:\Temp> Get-AzureRmResourceGroup
C:\Temp> |
@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. |
@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
Can you please clarify? |
@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
C:\> Get-Module -ListAvailable
C:> |
@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 |
@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. 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:\> |
@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).
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) With version 4.0.1 I get an error message on all cmdlets I use when connected to the MSDN tenant. |
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. |
@Marc013 @webbdog28 I missed the |
@markcowl To reproduce the reported issue I performed the described steps in my previous comment, noting more, nothing less. |
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. |
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: 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. 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. |
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 |
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: |
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. |
I can confirm that I am also seeing the reported issue regarding Import-AzureRmContext and then calling Get-AzureRmResourceGroup after that. I also tried the workaround regarding Set-AzureRmContext, but just like @SiloReed I then get a different error: |
+1, after updating to AzureRM.Profile 3.0.0 (AzureRM 4.0.0) this problem appeared. |
+1 repros for me. Your Azure credentials have not been set up or have expired, please run Login-AzureRMAccount to set up your Azure credentials. Installed profile modules are... Script 3.0.1 AzureRM.profile {Disable-AzureRmDataCollection, Enable-AzureRmDataCollection, Remove-AzureRmEnvironm... |
The same here. Workaround helped |
I am getting the same problem, the workaround only helps if the following was executed prior to calling
This defeats the purpose of caching the authentication in the first place Effectively Import-AzureRmContext does not work. Reproduction Steps
|
Same issue here, i have 2.6.0 and 3.0.1 installed - no issued before with import-azurermprofile. |
+1 I'm experiencing the same issue on many computers. |
@ashley7070 Moving the context from one machine to another is an explicit non-goal of this cmdlet. |
@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. |
@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 😄 |
@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 |
@pixelicous @guillemsola there will be |
@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... |
@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. |
@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 :) |
@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 |
@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 |
Here's what I did to make it work for me:
Into the Script I explicitly imported version 3.8.0 Here's the sample script:
I have tested this with two different subscriptions and it works like charm............ |
@SwapnilGoad @markcowl 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! |
@Marc013 lol, i didn't even think about that, yeah, that sounds like a real blocker. |
@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 Have filed two issues to fix, slated for the July release (7/7). Meanwhile, will work on a workaround for you in the interim. |
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 |
Actually, here is a simpler workaround: $ctx = Import-AzureRmContext -Path <path-to-saved-context>
$ctx.Context.TokenCache.Deserialize($ctx.Context.TokenCache.CacheData) |
The first may fix the issue permanently on a machine. The second would need to be run each time you imported the context |
@markcowl |
Fix shipped |
This fix can be found in version 4.2.0 of Azure PowerShell |
@markcowl It doesn't appear that these fixes have been applied to PowerShell v6.0.0-beta7 for Linux or Mac OS:
Any thoughts on this? |
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? |
@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. |
@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 will reproduce and open a new issue |
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 :
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.
The text was updated successfully, but these errors were encountered: