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

Connect-AzureRmAccount returns empty response when there are no subscriptions

Open bganapa opened this issue 8 years ago • 4 comments

Description

With the latest 5.6.0 azurerm.profile module we see that, connect-azurermaccount returns empty response like below when there are no subscriptions associated with the account logged in. This is a regression from the earlier version that azurestack is using.

The response from the latest AzureRm.Profile

Account          : 
SubscriptionName : 
SubscriptionId   : 
TenantId         : 
Environment      : 

Response from 3.4.1 version of the AzureRm.Profile

Account          : [email protected]
SubscriptionName : 
SubscriptionId   : 
TenantId         : xxxxxxx-xxxxx-xxx-xxxx-xxxxxxxxxx
Environment      : AzureCloud

Module Version

5.6.0 - AzureRm.Profile

Environment Data

Debug Output

PS C:\Windows\system32> $azureAccount = Add-AzureRmAccount -EnvironmentName 'AzureCloud' -TenantId '104edf09-7fc1-459f-8c4e-b062db480b90' -Verbose -Debug
DEBUG: 11:17:50 PM - ConnectAzureRmAccountCommand begin processing with ParameterSet 'UserWithSubscriptionId'.
DEBUG: 11:17:52 PM - Autosave setting from startup session: 'Process'
DEBUG: 11:17:52 PM - No autosave setting detected in environment variable 'AzureRmContextAutoSave'. 
DEBUG: 11:17:52 PM - Using Autosave scope 'Process'
DEBUG: 11:17:53 PM - Autosave setting from startup session: 'Process'
DEBUG: 11:17:53 PM - No autosave setting detected in environment variable 'AzureRmContextAutoSave'. 
DEBUG: 11:17:53 PM - Using Autosave scope 'Process'
DEBUG: [Common.Authentication]: Authenticating using configuration values: Domain: '104edf09-7fc1-459f-8c4e-b062db480b90', Endpoint: 'https://login.microsoftonline.com/', ClientId: '1950a258-227b-4e31-a9cf-717495945fc2', ClientRe
direct: 'urn:ietf:wg:oauth:2.0:oob', ResourceClientUri: 'https://management.core.windows.net/', ValidateAuthrity: 'True'
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 10/02/2018 23:17:53:  - 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/104edf09-7fc1-459f-8c4e-b062db480b90/', CorrelationId: '00000000-0000-0000-0000-000000000000', ValidateAuthority: 'Tr
ue'
DEBUG: [Common.Authentication]: Acquiring token using AdalConfiguration with Domain: '104edf09-7fc1-459f-8c4e-b062db480b90', AdEndpoint: 'https://login.microsoftonline.com/', ClientId: '1950a258-227b-4e31-a9cf-717495945fc2', Clie
ntRedirectUri: urn:ietf:wg:oauth:2.0:oob
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 10/02/2018 23:17:53: fb08c6ad-e083-4740-9338-c58bdfb1b57b - AcquireTokenHandlerBase: === Token Acquisition started:
       Authority: https://login.microsoftonline.com/104edf09-7fc1-459f-8c4e-b062db480b90/
       Resource: https://management.core.windows.net/
       ClientId: 1950a258-227b-4e31-a9cf-717495945fc2
       CacheType: Microsoft.Azure.Commands.Common.Authentication.AuthenticationStoreTokenCache (0 items)
       Authentication Target: User
       

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 10/02/2018 23:17:53:  - WindowsFormsWebAuthenticationDialogBase: Navigating to 'https://login.microsoftonline.com/104edf09-7fc1-459f-8c4e-b062db480b90/oauth2/authorize?resource=https://management.core.windows.net/&client_i
d=1950a258-227b-4e31-a9cf-717495945fc2&response_type=code&haschrome=1&redirect_uri=urn:ietf:wg:oauth:2.0:oob&client-request-id=fb08c6ad-e083-4740-9338-c58bdfb1b57b&prompt=login&amr_values=pwd&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: 10/02/2018 23:17:53:  - WindowsFormsWebAuthenticationDialogBase: Navigated to 'https://login.microsoftonline.com/104edf09-7fc1-459f-8c4e-b062db480b90/oauth2/authorize?resource=https://management.core.windows.net/&client_id
=1950a258-227b-4e31-a9cf-717495945fc2&response_type=code&haschrome=1&redirect_uri=urn:ietf:wg:oauth:2.0:oob&client-request-id=fb08c6ad-e083-4740-9338-c58bdfb1b57b&prompt=login&amr_values=pwd&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: 10/02/2018 23:18:05:  - WindowsFormsWebAuthenticationDialogBase: Navigating to 'https://login.microsoftonline.com/104edf09-7fc1-459f-8c4e-b062db480b90/login'.

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 10/02/2018 23:18:06:  - WindowsFormsWebAuthenticationDialogBase: WebBrowser state: IsBusy: True, ReadyState: Complete, Created: True, Disposing: False, IsDisposed: False, IsOffline: False

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 10/02/2018 23:18:06:  - 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: 10/02/2018 23:18:06: fb08c6ad-e083-4740-9338-c58bdfb1b57b - TokenCache: Storing token in the cache...

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 10/02/2018 23:18:06: fb08c6ad-e083-4740-9338-c58bdfb1b57b - TokenCache: An item was stored in the cache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 10/02/2018 23:18:06: fb08c6ad-e083-4740-9338-c58bdfb1b57b - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token was retuned:
       Access Token Hash: ilZO5tJeiiqnVYEIzevDDyrwW1aE2iOkXmKsaqF5Ukw=
       Refresh Token Hash: ppTVSDuehgJc0Kz5+pSJH55ACaHQOhhSPTiZ7osNCUU=
       Expiration Time: 10/03/2018 00:18:06 +00:00
       User Hash: 8lZX9zWoY7bnnw7FwO+tSixJ7kgiTs1gLVf54rVy8qA=
       

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 10/02/2018 23:18:06:  - 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        : a5364bf9-ec74-46a6-8add-fe08a8b0e5cf
accept-language               : en-US

Body:



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

Status Code:
OK

Headers:
Pragma                        : no-cache
x-ms-ratelimit-remaining-tenant-reads: 11999
x-ms-request-id               : 7b544658-8abc-462e-989b-177793897c21
x-ms-correlation-request-id   : 7b544658-8abc-462e-989b-177793897c21
x-ms-routing-request-id       : WESTUS2:20181002T231807Z:7b544658-8abc-462e-989b-177793897c21
Strict-Transport-Security     : max-age=31536000; includeSubDomains
X-Content-Type-Options        : nosniff
Cache-Control                 : no-cache
Date                          : Tue, 02 Oct 2018 23:18:06 GMT

Body:
{
  "value": []
}


DEBUG: 11:18:07 PM - ConnectAzureRmAccountCommand end processing.
DEBUG: 11:18:07 PM - ConnectAzureRmAccountCommand end processing.

PS C:\Windows\system32> $azureAccount


Account          : 
SubscriptionName : 
SubscriptionId   : 
TenantId         : 
Environment      : 

bganapa avatar Oct 02 '18 23:10 bganapa

In this case, we should create a context with account/environment/tenant

Note that we should also have a regression test for this behavior

markcowl avatar Oct 03 '18 23:10 markcowl

@markcowl , not sure I understood who has the AI and what it is, could you please clarify? We have at least 3 customer ICMs currently because of this regression.

knithinc avatar Oct 05 '18 21:10 knithinc

This is applicable to Az Module Connect-AzAccount as well

bganapa avatar Oct 18 '18 23:10 bganapa

This has been fixed and will be available in the next release (2018-11-06)

cormacpayne avatar Oct 26 '18 16:10 cormacpayne