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

Guid Error on connect-azurermaccount and others #6410

Closed
jasonpnnl opened this issue Jun 6, 2018 · 13 comments
Closed

Guid Error on connect-azurermaccount and others #6410

jasonpnnl opened this issue Jun 6, 2018 · 13 comments

Comments

@jasonpnnl
Copy link

Description

Receive Guid should contain 32 digits with 4 dashes when running some azure powershell commands, including connect-azurermaccount with cert auth.

Script/Steps for Reproduction

connect-azurermaccount -ServicePrincipal -CertificateThumbprint $thumbprint -ApplicationId <valid application id> -TenantId <valid azure ad tenant>

Other example:
$gid = Get-AzureRmADGroup -SearchString "<searchstring>" | select -ExpandProperty Id | select -ExpandProperty Guid
  New-AzureRmRoleAssignment -ObjectId $gid -RoleDefinitionName "Owner" -Scope /subscriptions/$subscriptionId

It does not happen all the time. Unknown what causes it to start working again and then break again.

Module Version

Get-Module -Name AzureRM -ListAvailable



    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     6.2.1      AzureRM
Script     6.1.1      AzureRM
Script     4.3.1      AzureRM

Environment Data

$PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.16299.431
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.16299.431
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Debug Output

DEBUG: 3:26:16 PM - ConnectAzureRmAccountCommand begin processing with ParameterSet 'ServicePrincipalCertificateWithSubscriptionId'.
DEBUG: 3:26:16 PM - using account id '<valid account id>'...
DEBUG: 3:26:16 PM - Autosave setting from startup session: 'CurrentUser'
DEBUG: 3:26:16 PM - No autosave setting detected in environment variable 'AzureRmContextAutoSave'.
DEBUG: 3:26:16 PM - Using Autosave scope 'CurrentUser'
DEBUG: [Common.Authentication]: Authenticating using configuration values: Domain: '<valid tenant>', Endpoint: 'https://login.microsoftonline.com/', ClientId:
'1950a258-227b-4e31-a9cf-717495945fc2', ClientRedirect: 'urn:ietf:wg:oauth:2.0:oob', ResourceClientUri: 'https://management.core.windows.net/', ValidateAuthrity: 'True'
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/06/2018 22:26:16: d14ad214-3725-4bc9-9397-44359a0ab7d4 - AcquireTokenHandlerBase: === Token Acquisition started:
 Authority: https://login.microsoftonline.com/pnnl.gov/
 Resource: https://management.core.windows.net/
 ClientId: 0a7d2d95-45ce-4cce-89c9-115eb5ad677a
 CacheType: Microsoft.Azure.Commands.Common.Authentication.ProtectedFileTokenCache (5 items)
 Authentication Target: Client

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/06/2018 22:26:16:  - TokenCache: Deserialized 5 items to token cache.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 06/06/2018 22:26:16: <removed> - TokenCache: Looking up cache for a token...
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/06/2018 22:26:16: <removed> - TokenCache: An item matching the requested resource was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 06/06/2018 22:26:16: <removed> - TokenCache: 30.4629764233333 minutes left until token in cache expires
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/06/2018 22:26:16: <removed> - TokenCache: A matching item (access token or refresh token or both) was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/06/2018 22:26:16: <removed> - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token was retuned:
 Access Token Hash: <removed>
 Refresh Token Hash: [No Refresh Token]
 Expiration Time: 06/06/2018 22:56:44 +00:00
 User Hash: null

DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

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

Headers:
x-ms-client-request-id        : <removed>
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               : <removed>
x-ms-correlation-request-id   : <removed>
x-ms-routing-request-id       : NORTHCENTRALUS:20180606T222617Z:<removed>
Strict-Transport-Security     : max-age=31536000; includeSubDomains
X-Content-Type-Options        : nosniff
Cache-Control                 : no-cache
Date                          : Wed, 06 Jun 2018 22:26:17 GMT

Body:
{
  "value": [
    {
      "id": "/subscriptions/<removed>",
      "subscriptionId": "<removed>",
      "displayName": "<removed>",
      "state": "Enabled",
      "subscriptionPolicies": {
        "locationPlacementId": "Public_2014-09-01",
        "quotaId": "EnterpriseAgreement_2014-09-01",
        "spendingLimit": "Off"
      },
      "authorizationSource": "RoleBased"
    },
    {
      "id": "/subscriptions/<removed>",
      "subscriptionId": "<removed>",
      "displayName": "<removed>",
      "state": "Enabled",
      "subscriptionPolicies": {
        "locationPlacementId": "Public_2014-09-01",
        "quotaId": "EnterpriseAgreement_2014-09-01",
        "spendingLimit": "Off"
      },
      "authorizationSource": "RoleBased"
    },
    {
      "id": "/subscriptions/<removed>",
      "subscriptionId": "<removed>",
      "displayName": "<removed>",
      "state": "Enabled",
      "subscriptionPolicies": {
        "locationPlacementId": "Public_2014-09-01",
        "quotaId": "MSDNDevTest_2014-09-01",
        "spendingLimit": "Off"
      },
      "authorizationSource": "RoleBased"
    },
    {
      "id": "/subscriptions/<removed>",
      "subscriptionId": "<removed>",
      "displayName": "<removed>",
      "state": "Enabled",
      "subscriptionPolicies": {
        "locationPlacementId": "Public_2014-09-01",
        "quotaId": "MSDNDevTest_2014-09-01",
        "spendingLimit": "Off"
      },
      "authorizationSource": "RoleBased"
    },
    {
      "id": "/subscriptions/<removed>",
      "subscriptionId": "<removed>",
      "displayName": "<removed>",
      "state": "Enabled",
      "subscriptionPolicies": {
        "locationPlacementId": "Public_2014-09-01",
        "quotaId": "EnterpriseAgreement_2014-09-01",
        "spendingLimit": "Off"
      },
      "authorizationSource": "RoleBased"
    },
    {
      "id": "/subscriptions/<removed>",
      "subscriptionId": "<removed>",
      "displayName": "<removed>",
      "state": "Enabled",
      "subscriptionPolicies": {
        "locationPlacementId": "Public_2014-09-01",
        "quotaId": "EnterpriseAgreement_2014-09-01",
        "spendingLimit": "Off"
      },
      "authorizationSource": "RoleBased"
    },
    {
      "id": "/subscriptions/<removed>",
      "subscriptionId": "<removed>",
      "displayName": "<removed>",
      "state": "Enabled",
      "subscriptionPolicies": {
        "locationPlacementId": "Public_2014-09-01",
        "quotaId": "MSDNDevTest_2014-09-01",
        "spendingLimit": "Off"
      },
      "authorizationSource": "RoleBased"
    },
    {
      "id": "/subscriptions/<removed>",
      "subscriptionId": "<removed>",
      "displayName": "<removed>",
      "state": "Enabled",
      "subscriptionPolicies": {
        "locationPlacementId": "Public_2014-09-01",
        "quotaId": "MSDNDevTest_2014-09-01",
        "spendingLimit": "Off"
      },
      "authorizationSource": "RoleBased"
    }
  ]
}

connect-azurermaccount : Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
At line:1 char:1
+ connect-azurermaccount -ServicePrincipal -CertificateThumbprint $thum ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Connect-AzureRmAccount], FormatException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand

DEBUG: AzureQoSEvent: CommandName - Connect-AzureRmAccount; IsSuccess - False; Duration - 00:00:01.5232537; Exception - System.FormatException: Guid should contain 32 digits with 4
dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
   at System.Guid.GuidResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument, String failureArgumentName, Exception innerException)
   at System.Guid.TryParseGuidWithNoStyle(String guidString, GuidResult& result)
   at System.Guid.TryParseGuid(String g, GuidStyles flags, GuidResult& result)
   at System.Guid..ctor(String g)
   at Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureTenantExtensions.GetId(IAzureTenant tenant)
   at Microsoft.Azure.Commands.Common.Authentication.Models.AzureRmProfile.<>c__DisplayClass45_0.<TryFindContext>b__0(KeyValuePair`2 c)
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
   at Microsoft.Azure.Commands.Common.Authentication.Models.AzureRmProfile.TryFindContext(IAzureContext context, String& name)
   at Microsoft.Azure.Commands.Common.Authentication.Models.AzureRmProfile.TrySetDefaultContext(IAzureContext context)
   at Microsoft.Azure.Commands.Common.Authentication.ResourceManager.AzureRmAutosaveProfile.TrySetDefaultContext(IAzureContext context)
   at Microsoft.Azure.Commands.Common.Authentication.ResourceManager.AzureRmAutosaveProfile.TrySetDefaultContext(String name, IAzureContext context)
   at Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.Login(IAzureAccount account, IAzureEnvironment environment, String tenantId, String subscriptionId, String
subscriptionName, SecureString password, Boolean skipValidation, Action`1 promptAction, String name)
   at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.<>c__DisplayClass83_0.<ExecuteCmdlet>b__0(AzureRmProfile localProfile, RMProfileClient profileClient, String name)
   at Microsoft.Azure.Commands.Profile.Common.AzureContextModificationCmdlet.ModifyContext(Action`2 contextAction)
   at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.SetContextWithOverwritePrompt(Action`3 setContextAction)
   at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.ExecuteCmdlet()
   at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();
DEBUG: Finish sending metric.
DEBUG: 3:26:18 PM - ConnectAzureRmAccountCommand end processing.
DEBUG: 3:26:18 PM - ConnectAzureRmAccountCommand end processing.
Resolve-AzureRmError
   HistoryId: 10


Message        : Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
StackTrace     :    at System.Guid.GuidResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument, String failureArgumentName, Exception
                 innerException)
                    at System.Guid.TryParseGuidWithNoStyle(String guidString, GuidResult& result)
                    at System.Guid.TryParseGuid(String g, GuidStyles flags, GuidResult& result)
                    at System.Guid..ctor(String g)
                    at Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureTenantExtensions.GetId(IAzureTenant tenant)
                    at Microsoft.Azure.Commands.Common.Authentication.Models.AzureRmProfile.<>c__DisplayClass45_0.<TryFindContext>b__0(KeyValuePair`2 c)
                    at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
                    at Microsoft.Azure.Commands.Common.Authentication.Models.AzureRmProfile.TryFindContext(IAzureContext context, String& name)
                    at Microsoft.Azure.Commands.Common.Authentication.Models.AzureRmProfile.TrySetDefaultContext(IAzureContext context)
                    at Microsoft.Azure.Commands.Common.Authentication.ResourceManager.AzureRmAutosaveProfile.TrySetDefaultContext(IAzureContext context)
                    at Microsoft.Azure.Commands.Common.Authentication.ResourceManager.AzureRmAutosaveProfile.TrySetDefaultContext(String name, IAzureContext context)
                    at Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.Login(IAzureAccount account, IAzureEnvironment environment, String tenantId, String
                 subscriptionId, String subscriptionName, SecureString password, Boolean skipValidation, Action`1 promptAction, String name)
                    at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.<>c__DisplayClass83_0.<ExecuteCmdlet>b__0(AzureRmProfile localProfile, RMProfileClient
                 profileClient, String name)
                    at Microsoft.Azure.Commands.Profile.Common.AzureContextModificationCmdlet.ModifyContext(Action`2 contextAction)
                    at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.SetContextWithOverwritePrompt(Action`3 setContextAction)
                    at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.ExecuteCmdlet()
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception      : System.FormatException
InvocationInfo : {Connect-AzureRmAccount}
Line           : connect-azurermaccount -ServicePrincipal -CertificateThumbprint $thumbprint -ApplicationId <removed> -TenantId <removed>
Position       : At line:1 char:1
                 + connect-azurermaccount -ServicePrincipal -CertificateThumbprint $thum ...
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 10
@markcowl
Copy link
Member

markcowl commented Jun 7, 2018

@jasonpnnl The call stack is complaining about the tenant id. Are you providing a GUID tenant ID in this case, or are you providing the tenant name?

@jasonpnnl
Copy link
Author

@markcowl thanks for your question. The same thing happens with both. I have tried supplying the tenant ID as a GUID or as the tenant name. Primarily I use the tenant name. Sometimes the Connect-AzureRmAccount will succeed with the tenant name, more frequently it fails with the above error. This was not happening prior to a week or two ago. I updated AzureRM modules and started using cert auth about this time.

@jasonpnnl
Copy link
Author

Debug output when using GUID tenantID in case this helps.

connect-azurermaccount -ServicePrincipal -CertificateThumbprint $thumbprint -ApplicationId <applicationid guid> -TenantId <tenantid guid>
DEBUG: 12:46:33 PM - ConnectAzureRmAccountCommand begin processing with ParameterSet 'ServicePrincipalCertificateWithSubscriptionId'.
DEBUG: 12:46:33 PM - using account id '<removed>'...
DEBUG: 12:46:33 PM - Autosave setting from startup session: 'CurrentUser'
DEBUG: 12:46:33 PM - No autosave setting detected in environment variable 'AzureRmContextAutoSave'.
DEBUG: 12:46:33 PM - Using Autosave scope 'CurrentUser'
DEBUG: [Common.Authentication]: Authenticating using configuration values: Domain: '<removed>', Endpoint: 'https://login.microsoftonline.com/', ClientId:
'<removed>', ClientRedirect: 'urn:ietf:wg:oauth:2.0:oob', ResourceClientUri: 'https://management.core.windows.net/', ValidateAuthrity: 'True'
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/07/2018 19:46:33: <removed> - AcquireTokenHandlerBase: === Token Acquisition started:
 Authority: https://login.microsoftonline.com/<removed>/
 Resource: https://management.core.windows.net/
 ClientId: <removed>
 CacheType: Microsoft.Azure.Commands.Common.Authentication.ProtectedFileTokenCache (3 items)
 Authentication Target: Client

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/07/2018 19:46:33:  - TokenCache: Deserialized 3 items to token cache.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 06/07/2018 19:46:33: <removed> - TokenCache: Looking up cache for a token...
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/07/2018 19:46:33: <removed> - TokenCache: An item matching the requested resource was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 06/07/2018 19:46:33: <removed> - TokenCache: 52.9762195933333 minutes left until token in cache expires
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/07/2018 19:46:33: <removed> - TokenCache: A matching item (access token or refresh token or both) was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/07/2018 19:46:33: <removed> - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token was retuned:
 Access Token Hash: <removed>
 Refresh Token Hash: [No Refresh Token]
 Expiration Time: 06/07/2018 20:39:32 +00:00
 User Hash: null

DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

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

Headers:
x-ms-client-request-id        : <removed>
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               : 2ce79668-6799-4ccb-b7d4-c1facb894705
x-ms-correlation-request-id   : 2ce79668-6799-4ccb-b7d4-c1facb894705
x-ms-routing-request-id       : NORTHCENTRALUS:20180607T194634Z:2ce79668-6799-4ccb-b7d4-c1facb894705
Strict-Transport-Security     : max-age=31536000; includeSubDomains
X-Content-Type-Options        : nosniff
Cache-Control                 : no-cache
Date                          : Thu, 07 Jun 2018 19:46:33 GMT

Body:
{
<snip>
  ]
}

connect-azurermaccount : Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
At line:1 char:1
+ connect-azurermaccount -ServicePrincipal -CertificateThumbprint $thum ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Connect-AzureRmAccount], FormatException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand

DEBUG: AzureQoSEvent: CommandName - Connect-AzureRmAccount; IsSuccess - False; Duration - 00:00:01.3216099; Exception - System.FormatException: Guid should contain 32 digits with 4
dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
   at System.Guid.GuidResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument, String failureArgumentName, Exception innerException)
   at System.Guid.TryParseGuidWithNoStyle(String guidString, GuidResult& result)
   at System.Guid.TryParseGuid(String g, GuidStyles flags, GuidResult& result)
   at System.Guid..ctor(String g)
   at Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureTenantExtensions.GetId(IAzureTenant tenant)
   at Microsoft.Azure.Commands.Common.Authentication.Models.AzureRmProfile.<>c__DisplayClass45_0.<TryFindContext>b__0(KeyValuePair`2 c)
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
   at Microsoft.Azure.Commands.Common.Authentication.Models.AzureRmProfile.TryFindContext(IAzureContext context, String& name)
   at Microsoft.Azure.Commands.Common.Authentication.Models.AzureRmProfile.TrySetDefaultContext(IAzureContext context)
   at Microsoft.Azure.Commands.Common.Authentication.ResourceManager.AzureRmAutosaveProfile.TrySetDefaultContext(IAzureContext context)
   at Microsoft.Azure.Commands.Common.Authentication.ResourceManager.AzureRmAutosaveProfile.TrySetDefaultContext(String name, IAzureContext context)
   at Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.Login(IAzureAccount account, IAzureEnvironment environment, String tenantId, String subscriptionId, String
subscriptionName, SecureString password, Boolean skipValidation, Action`1 promptAction, String name)
   at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.<>c__DisplayClass83_0.<ExecuteCmdlet>b__0(AzureRmProfile localProfile, RMProfileClient profileClient, String name)
   at Microsoft.Azure.Commands.Profile.Common.AzureContextModificationCmdlet.ModifyContext(Action`2 contextAction)
   at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.SetContextWithOverwritePrompt(Action`3 setContextAction)
   at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.ExecuteCmdlet()
   at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();
DEBUG: Finish sending metric.
DEBUG: 12:46:35 PM - ConnectAzureRmAccountCommand end processing.
DEBUG: 12:46:35 PM - ConnectAzureRmAccountCommand end processing.```

@cormacpayne
Copy link
Member

@jasonpnnl Hey Jason, would you mind running Clear-AzureRmContext -Scope Process and then running Connect-AzureRmAccount in a new PowerShell session? If that doesn't work, try opening a new PowerShell session and running the previous commands, but before doing so, run Disable-AzureRmContextAutosave

@maddieclayton
Copy link
Contributor

Closing this issue for inactivity. @jasonpnnl If you still run into this issue after following the instructions in the previous comment, feel free to reopen.

@lanndoc
Copy link

lanndoc commented Jul 25, 2018

Still receiving this error.

@maddieclayton maddieclayton reopened this Jul 25, 2018
@maddieclayton
Copy link
Contributor

@lanndoc Are you running the most current version of AzureRM, and have you tried running the commands Cormac described above?

@lanndoc
Copy link

lanndoc commented Jul 26, 2018 via email

@joslevin
Copy link

Hi,

I hit the exact same issue, and wasted about half a day trying to figure out what was wrong.

Running Clear-AzureRmContext -Scope Process fixed it. It would be good if there was (at least) a more helpful error message in this context.

@jasonpnnl
Copy link
Author

Disable-AzureRmContextAutosave followed by Clear-AzureRmContext -Scope Process allowed the Connect-AzureRMAccount -CertificateThumbprint.

My question now is, how do I apply this workaround in the context of a script. Do I need to include something in each script to allow it to function or will this fix apply to all scripts?

Also, is this a bug? Is there something that needs to be fixed to make it so this workaround isn't necessary or is this working as intended? Can you help explain what is happening here?

@cormacpayne
Copy link
Member

@jasonpnnl @joslevin we are currently working on fixing this bug. This occurs when running Connect-AzureRmAccount with a service principal and passing a tenant domain to the -TenantId parameter instead of the tenant (GUID) id; doing this will put your Azure PowerShell sessions into a state where it can't access the current context because the tenant isn't in a GUID form (since it was provided the domain string), and the recommended way of getting out of this state is to delete the AzureRmContext.json and TokenCache.dat files found in %APPDATA%/Windows Azure PowerShell on your machine.

We plan on tracking the status of this bug with issue #6709

@jasonpnnl
Copy link
Author

@cormacpayne Thanks for your reply!

@cormacpayne
Copy link
Member

@jasonpnnl @joslevin candidate fix for this issue can be found in PR #6822

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

6 participants