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

Login-AzAccount or Connect-AzAccount throws an ecxeption

Open sndkr opened this issue 7 years ago • 15 comments

Description

Currently is it not possible to use the functions Login-AzAccount or Connect-AzAccount with an ADFS Login (Mail address and password).

Maybe it is the same error in your lib as described here - https://github.com/AzureAD/azure-activedirectory-library-for-dotnet/issues/699

Steps to reproduce

# the function Get-UserCredentials create a PSCredential object 
[System.Management.Automation.PSCredential] $userCred = Get-UserCredentials -Credentials $Credentials
Login-AzAccount -Credential $userCred

Environment data

 $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.17134.590
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17134.590
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Module versions

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.3.0      Az.Accounts                         {Disable-AzDataCollection, Disable-AzContextAutosave, Enab...
Script     1.0.1      Az.Aks                              {Get-AzAks, New-AzAks, Remove-AzAks, Import-AzAksCredentia...
Script     1.0.2      Az.AnalysisServices                 {Resume-AzAnalysisServicesServer, Suspend-AzAnalysisServic...
Script     1.0.0      Az.ApiManagement                    {Add-AzApiManagementRegion, Get-AzApiManagementSsoToken, N...
Script     1.0.0      Az.ApplicationInsights              {Get-AzApplicationInsights, New-AzApplicationInsights, Rem...
Script     1.1.1      Az.Automation                       {Get-AzAutomationHybridWorkerGroup, Remove-AzAutomationHyb...
Script     1.0.0      Az.Batch                            {Remove-AzBatchAccount, Get-AzBatchAccount, Get-AzBatchAcc...
Script     1.0.0      Az.Billing                          {Get-AzBillingInvoice, Get-AzBillingPeriod, Get-AzEnrollme...
Script     1.0.1      Az.Cdn                              {Get-AzCdnProfile, Get-AzCdnProfileSsoUrl, New-AzCdnProfil...
Script     1.0.1      Az.CognitiveServices                {Get-AzCognitiveServicesAccount, Get-AzCognitiveServicesAc...
Script     1.4.0      Az.Compute                          {Remove-AzAvailabilitySet, Get-AzAvailabilitySet, New-AzAv...
Script     1.0.0      Az.ContainerInstance                {New-AzContainerGroup, Get-AzContainerGroup, Remove-AzCont...
Script     1.0.1      Az.ContainerRegistry                {New-AzContainerRegistry, Get-AzContainerRegistry, Update-...
Script     1.0.1      Az.DataFactory                      {Set-AzDataFactoryV2, Update-AzDataFactoryV2, Get-AzDataFa...
Script     1.0.0      Az.DataLakeAnalytics                {Get-AzDataLakeAnalyticsDataSource, New-AzDataLakeAnalytic...
Script     1.1.0      Az.DataLakeStore                    {Get-AzDataLakeStoreTrustedIdProvider, Remove-AzDataLakeSt...
Script     1.0.0      Az.DevTestLabs                      {Get-AzDtlAllowedVMSizesPolicy, Get-AzDtlAutoShutdownPolic...
Script     1.0.0      Az.Dns                              {Get-AzDnsRecordSet, New-AzDnsRecordConfig, Remove-AzDnsRe...
Script     1.1.0      Az.EventGrid                        {New-AzEventGridTopic, Get-AzEventGridTopic, Set-AzEventGr...
Script     1.0.1      Az.EventHub                         {New-AzEventHubNamespace, Get-AzEventHubNamespace, Set-AzE...
Script     1.0.0      Az.HDInsight                        {Get-AzHDInsightJob, New-AzHDInsightSqoopJobDefinition, Wa...
Script     1.0.2      Az.IotHub                           {Add-AzIotHubKey, Get-AzIotHubEventHubConsumerGroup, Get-A...
Script     1.0.2      Az.KeyVault                         {Add-AzKeyVaultCertificate, Update-AzKeyVaultCertificate, ...
Script     1.2.0      Az.LogicApp                         {Get-AzIntegrationAccountAgreement, Get-AzIntegrationAccou...
Script     1.0.0      Az.MachineLearning                  {Move-AzMlCommitmentAssociation, Get-AzMlCommitmentAssocia...
Script     1.0.0      Az.MarketplaceOrdering              {Get-AzMarketplaceTerms, Set-AzMarketplaceTerms}
Script     1.0.0      Az.Media                            {Sync-AzMediaServiceStorageKeys, Set-AzMediaServiceKey, Ge...
Script     1.0.1      Az.Monitor                          {Get-AzMetricDefinition, Get-AzMetric, Remove-AzLogProfile...
Script     1.2.1      Az.Network                          {Add-AzApplicationGatewayAuthenticationCertificate, Get-Az...
Script     1.0.0      Az.NotificationHubs                 {Get-AzNotificationHub, Get-AzNotificationHubAuthorization...
Script     1.1.0      Az.OperationalInsights              {New-AzOperationalInsightsAzureActivityLogDataSource, New-...
Script     1.0.0      Az.PolicyInsights                   {Get-AzPolicyEvent, Get-AzPolicyState, Get-AzPolicyStateSu...
Script     1.0.0      Az.PowerBIEmbedded                  {Remove-AzPowerBIWorkspaceCollection, Get-AzPowerBIWorkspa...
Script     1.0.1      Az.RecoveryServices                 {Get-AzRecoveryServicesBackupProperty, Get-AzRecoveryServi...
Script     1.0.0      Az.RedisCache                       {Remove-AzRedisCachePatchSchedule, New-AzRedisCacheSchedul...
Script     1.0.0      Az.Relay                            {New-AzRelayNamespace, Get-AzRelayNamespace, Set-AzRelayNa...
Script     1.1.3      Az.Resources                        {Get-AzProviderOperation, Remove-AzRoleAssignment, Get-AzR...
Script     1.0.0      Az.ServiceBus                       {New-AzServiceBusNamespace, Get-AzServiceBusNamespace, Set...
Script     1.0.1      Az.ServiceFabric                    {Add-AzServiceFabricApplicationCertificate, Add-AzServiceF...
Script     1.0.2      Az.SignalR                          {New-AzSignalR, Get-AzSignalR, Get-AzSignalRKey, New-AzSig...
Script     1.3.0      Az.Sql                              {Get-AzSqlDatabaseTransparentDataEncryption, Get-AzSqlData...
Script     1.0.2      Az.Storage                          {Get-AzStorageAccount, Get-AzStorageAccountKey, New-AzStor...
Script     1.0.0      Az.StreamAnalytics                  {Get-AzStreamAnalyticsFunction, Get-AzStreamAnalyticsDefau...
Script     1.0.1      Az.TrafficManager                   {Add-AzTrafficManagerCustomHeaderToEndpoint, Remove-AzTraf...
Script     1.1.1      Az.Websites                         {Get-AzAppServicePlan, Set-AzAppServicePlan, New-AzAppServ...

Debug output


Error output


Login-AzAccount : Federated service at https://[adfsUrl]/adfs/services/trust/13/usernamemixed returned error: ID3035: The request was not valid or is malformed.
In [PathToMyPsScript]:637 Zeichen:13
+             Login-AzAccount -Credential $userCred
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Connect-AzAccount], AdalServiceException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand

sndkr avatar Feb 27 '19 15:02 sndkr

@sndkr Can you provide the output when running this command with $DebugPreference="Continue"? Also, after the error, please execute Resolve-AzureRmError

markcowl avatar Feb 27 '19 16:02 markcowl

@markcowl - Thanks for your comment - here the Debug informations.

Debug Output

DEBUG: 08:58:57 - ConnectAzureRmAccountCommand begin processing with ParameterSet 'UserWithCredential'.
DEBUG: 08:58:57 - Autosave setting from startup session: 'Process'
DEBUG: 08:58:57 - No autosave setting detected in environment variable 'AzContextAutoSave'. 
DEBUG: 08:58:57 - Using Autosave scope 'Process'
Login-AzAccount : Federated service at https://[AdfsUrl]/adfs/services/trust/13/usernamemixed returned error: ID3035: The request was not valid or is malformed.
In [PsFilePath].ps1:638 Zeichen:13
+             Login-AzAccount -Credential $userCred
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Connect-AzAccount], AdalServiceException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand
 
DEBUG: AzureQoSEvent: CommandName - Connect-AzAccount; IsSuccess - False; Duration - 00:00:00.6432918; Exception - Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException: Federated service at https://[AdfsUrl]/adfs/services/trust/13/usernamemixed returned error: ID3035: The request was not valid or is malformed. ---> System.Net.Http.HttpRequestException:  Response status code does not indicate success: 500 (InternalServerError). ---> System.Exception: <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><s:Header><a:Action s:mustUnderstand="1">http://www.w3.org/2005/08/addressing/soap/fault</a:Action><a:RelatesTo>urn:uuid:175ce76f-ac0f-49e7-8603-a369cc6a9ad2</a:RelatesTo><o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><u:Timestamp u:Id="_0"><u:Created>2019-02-28T07:58:58.086Z</u:Created><u:Expires>2019-02-28T08:03:58.086Z</u:Expires></u:Timestamp></o:Security></s:Header><s:Body><s:Fault><s:Code><s:Value>s:Sender</s:Value><s:Subcode><s:Value xmlns:a="http://docs.oasis-open.org/ws-sx/ws-trust/200512">a:InvalidRequest</s:Value></s:Subcode></s:Code><s:Reason><s:Text xml:lang="de-DE">ID3035: The request was not valid or is malformed.</s:Text></s:Reason></s:Fault></s:Body></s:Envelope>
   --- Ende der internen Ausnahmestapelüberwachung ---
   bei Microsoft.IdentityModel.Clients.ActiveDirectory.HttpClientWrapper.<GetResponseAsync>d__30.MoveNext()
   --- Ende der internen Ausnahmestapelüberwachung ---
   bei Microsoft.IdentityModel.Clients.ActiveDirectory.WsTrustRequest.<SendRequestAsync>d__3.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenNonInteractiveHandler.<PreTokenRequest>d__5.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenHandlerBase.<RunAsync>d__55.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext.<AcquireTokenCommonAsync>d__52.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContextIntegratedAuthExtensions.<AcquireTokenAsync>d__0.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei Microsoft.Azure.PowerShell.Authenticators.AuthenticationResultToken.<GetAccessTokenAsync>d__11.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei Microsoft.Azure.Commands.Common.Authentication.Factories.AuthenticationFactory.Authenticate(IAzureAccount account, IAzureEnvironment environment, String tenant, SecureString password, String promptBehavior, Action`1 promptAction, IAzureTokenCache tokenCache, String resourceId)
   bei Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.AcquireAccessToken(IAzureAccount account, IAzureEnvironment environment, String tenantId, SecureString password, String promptBehavior, Action`1 promptAction)
   bei Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.ListAccountTenants(IAzureAccount account, IAzureEnvironment environment, SecureString password, String promptBehavior, Action`1 promptAction)   bei 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, Boolean shouldPopulateContextList)
   bei Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.<>c__DisplayClass92_0.<ExecuteCmdlet>b__0(AzureRmProfile localProfile, RMProfileClient profileClient, String name)
   bei Microsoft.Azure.Commands.Profile.Common.AzureContextModificationCmdlet.ModifyContext(Action`2 contextAction)
   bei Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.SetContextWithOverwritePrompt(Action`3 setContextAction)
   bei Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.ExecuteCmdlet()
   bei Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
        ErrorCode: federated_service_returned_error
        StatusCode: 500;
DEBUG: Finish sending metric.
DEBUG: 08:58:58 - ConnectAzureRmAccountCommand end processing.
DEBUG: 08:58:58 - ConnectAzureRmAccountCommand end processing.
[DBG]: PS C:\D\OneDrive\Job\Alegri.Azure.Scripts>
DEBUG: 08:59:01 - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.


   HistoryId: 13


Message        : Federated service at https://[AdfsUrl]/adfs/services/trust/13/usernamemixed returned error: ID3035: The request was not valid or is malformed.
StackTrace     :    bei Microsoft.IdentityModel.Clients.ActiveDirectory.WsTrustRequest.<SendRequestAsync>d__3.MoveNext()
                 --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
                    bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                    bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                    bei Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenNonInteractiveHandler.<PreTokenRequest>d__5.MoveNext()
                 --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
                    bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                    bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                    bei Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenHandlerBase.<RunAsync>d__55.MoveNext()
                 --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
                    bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                    bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                    bei Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext.<AcquireTokenCommonAsync>d__52.MoveNext()
                 --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
                    bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                    bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                    bei Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContextIntegratedAuthExtensions.<AcquireTokenAsync>d__0.MoveNext()
                 --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
                    bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                    bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                    bei Microsoft.Azure.PowerShell.Authenticators.AuthenticationResultToken.<GetAccessTokenAsync>d__11.MoveNext()
                 --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
                    bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                    bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                    bei Microsoft.Azure.Commands.Common.Authentication.Factories.AuthenticationFactory.Authenticate(IAzureAccount account, IAzureEnvironment environment, String tenant, SecureString password,
                 String promptBehavior, Action`1 promptAction, IAzureTokenCache tokenCache, String resourceId)
                    bei Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.AcquireAccessToken(IAzureAccount account, IAzureEnvironment environment, String tenantId, SecureString password, String
                 promptBehavior, Action`1 promptAction)
                    bei Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.ListAccountTenants(IAzureAccount account, IAzureEnvironment environment, SecureString password, String promptBehavior,
                 Action`1 promptAction)
                    bei 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, Boolean shouldPopulateContextList)
                    bei Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.<>c__DisplayClass92_0.<ExecuteCmdlet>b__0(AzureRmProfile localProfile, RMProfileClient profileClient, String name)
                    bei Microsoft.Azure.Commands.Profile.Common.AzureContextModificationCmdlet.ModifyContext(Action`2 contextAction)
                    bei Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.SetContextWithOverwritePrompt(Action`3 setContextAction)
                    bei Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.ExecuteCmdlet()
                    bei Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception      : Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException
InvocationInfo : {Connect-AzAccount}
Line           :             Login-AzAccount -Credential $userCred

Position       : In [PsFilePath].ps1:638 Zeichen:13
                 +             Login-AzAccount -Credential $userCred
                 +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 13

Message        :  Response status code does not indicate success: 500 (InternalServerError).
StackTrace     :    bei Microsoft.IdentityModel.Clients.ActiveDirectory.HttpClientWrapper.<GetResponseAsync>d__30.MoveNext()
Exception      : System.Net.Http.HttpRequestException
InvocationInfo : {Connect-AzAccount}
Line           :             Login-AzAccount -Credential $userCred

Position       : In [PsFilePath].ps1:638 Zeichen:13
                 +             Login-AzAccount -Credential $userCred
                 +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 13

Message        : <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"
                 xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><s:Header><a:Action
                 s:mustUnderstand="1">http://www.w3.org/2005/08/addressing/soap/fault</a:Action><a:RelatesTo>urn:uuid:175ce76f-ac0f-49e7-8603-a369cc6a9ad2</a:RelatesTo><o:Security s:mustUnderstand="1"
                 xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><u:Timestamp u:Id="_0"><u:Created>2019-02-28T07:58:58.086Z</u:Created><u:Expires>2019-02-28T08:03:58.0
                 86Z</u:Expires></u:Timestamp></o:Security></s:Header><s:Body><s:Fault><s:Code><s:Value>s:Sender</s:Value><s:Subcode><s:Value
                 xmlns:a="http://docs.oasis-open.org/ws-sx/ws-trust/200512">a:InvalidRequest</s:Value></s:Subcode></s:Code><s:Reason><s:Text xml:lang="de-DE">ID3035: The request was not valid or is
                 malformed.</s:Text></s:Reason></s:Fault></s:Body></s:Envelope>
StackTrace     :
Exception      : System.Exception
InvocationInfo : {Connect-AzAccount}
Line           :             Login-AzAccount -Credential $userCred

Position       : In [PsFilePath].ps1:638 Zeichen:13
                 +             Login-AzAccount -Credential $userCred
                 +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 13



   HistoryId: -1


DEBUG: AzureQoSEvent: CommandName - Resolve-AzError; IsSuccess - True; Duration - 00:00:00.1422913; Exception - ;
DEBUG: Finish sending metric.
DEBUG: 08:59:01 - ResolveError end processing.
DEBUG: 08:59:01 - ResolveError end processing.

sndkr avatar Feb 28 '19 08:02 sndkr

I have also run into this issue. @sndkr Did you ever find a fix?

smithanc avatar Mar 05 '19 13:03 smithanc

@smithanc No, I did't find a fix for this problem. I hope of the next release.

sndkr avatar Mar 05 '19 13:03 sndkr

Just so the team is aware, I am not having this issue with Az.Accounts version 1.3.0 but I have the error on version 1.3.1. Not sure if that is somehow impacting or not.

smithanc avatar Mar 05 '19 13:03 smithanc

@markcowl see if the logging provided by https://github.com/Azure/azure-powershell/pull/8696 will help in getting more information for this issue

cormacpayne avatar Mar 05 '19 23:03 cormacpayne

@smithanc @sndkr This error indicates a communication problem with your local eSTS, we have just enabled additional debugging information in the version going out in the next release (3/12). If needed, we can make these bits available to you early for debugging purposes.

Also, does this occur when using interactive authentication, or when providing a PSCredential on the command line.

markcowl avatar Mar 07 '19 20:03 markcowl

@sndkr @smithanc There is a new version of the Az.Accounts module on the Test Gallery that will provide additional AD logging in the debug stream. If you are confortable with installing modules from the test repository, it would be helpful if you could gather additional debug logs for this issue:

Register-PSRepository -Name TestGallery -PackageManagementProvider NuGet -SourceLocation https://www.poshtestgallery.com/api/v2 -InstallationPolicy Trusted
Install-Module Az.Accounts -Repository TestGallery -AllowClobber -Force

then if you set $DebugPreference="Continue" and execute the failing login, we should be able to get more information about the failure.

markcowl avatar Mar 08 '19 19:03 markcowl

@markcowl Today I installed your test module - here the result of the module Az.Accounts V 1.4.0

Module versions

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.4.0      Az.Accounts                         {Disable-AzDataCollection, Disable-AzContextAutosave, Enab...
Script     1.3.1      Az.Accounts                         {Disable-AzDataCollection, Disable-AzContextAutosave, Enab...
Script     1.0.1      Az.Aks                              {Get-AzAks, New-AzAks, Remove-AzAks, Import-AzAksCredentia...
Script     1.0.2      Az.AnalysisServices                 {Resume-AzAnalysisServicesServer, Suspend-AzAnalysisServic...
Script     1.0.0      Az.ApiManagement                    {Add-AzApiManagementRegion, Get-AzApiManagementSsoToken, N...
Script     1.0.0      Az.ApplicationInsights              {Get-AzApplicationInsights, New-AzApplicationInsights, Rem...
Script     1.1.1      Az.Automation                       {Get-AzAutomationHybridWorkerGroup, Remove-AzAutomationHyb...
Script     1.0.0      Az.Batch                            {Remove-AzBatchAccount, Get-AzBatchAccount, Get-AzBatchAcc...
Script     1.0.0      Az.Billing                          {Get-AzBillingInvoice, Get-AzBillingPeriod, Get-AzEnrollme...
Script     1.0.1      Az.Cdn                              {Get-AzCdnProfile, Get-AzCdnProfileSsoUrl, New-AzCdnProfil...
Script     1.0.1      Az.CognitiveServices                {Get-AzCognitiveServicesAccount, Get-AzCognitiveServicesAc...
Script     1.4.0      Az.Compute                          {Remove-AzAvailabilitySet, Get-AzAvailabilitySet, New-AzAv...
Script     1.0.0      Az.ContainerInstance                {New-AzContainerGroup, Get-AzContainerGroup, Remove-AzCont...
Script     1.0.1      Az.ContainerRegistry                {New-AzContainerRegistry, Get-AzContainerRegistry, Update-...
Script     1.0.1      Az.DataFactory                      {Set-AzDataFactoryV2, Update-AzDataFactoryV2, Get-AzDataFa...
Script     1.0.0      Az.DataLakeAnalytics                {Get-AzDataLakeAnalyticsDataSource, New-AzDataLakeAnalytic...
Script     1.1.0      Az.DataLakeStore                    {Get-AzDataLakeStoreTrustedIdProvider, Remove-AzDataLakeSt...
Script     1.0.0      Az.DevTestLabs                      {Get-AzDtlAllowedVMSizesPolicy, Get-AzDtlAutoShutdownPolic...
Script     1.0.0      Az.Dns                              {Get-AzDnsRecordSet, New-AzDnsRecordConfig, Remove-AzDnsRe...
Script     1.1.0      Az.EventGrid                        {New-AzEventGridTopic, Get-AzEventGridTopic, Set-AzEventGr...
Script     1.0.1      Az.EventHub                         {New-AzEventHubNamespace, Get-AzEventHubNamespace, Set-AzE...
Script     1.0.0      Az.HDInsight                        {Get-AzHDInsightJob, New-AzHDInsightSqoopJobDefinition, Wa...
Script     1.0.2      Az.IotHub                           {Add-AzIotHubKey, Get-AzIotHubEventHubConsumerGroup, Get-A...
Script     1.0.2      Az.KeyVault                         {Add-AzKeyVaultCertificate, Update-AzKeyVaultCertificate, ...
Script     1.2.0      Az.LogicApp                         {Get-AzIntegrationAccountAgreement, Get-AzIntegrationAccou...
Script     1.0.0      Az.MachineLearning                  {Move-AzMlCommitmentAssociation, Get-AzMlCommitmentAssocia...
Script     1.0.0      Az.MarketplaceOrdering              {Get-AzMarketplaceTerms, Set-AzMarketplaceTerms}
Script     1.0.0      Az.Media                            {Sync-AzMediaServiceStorageKeys, Set-AzMediaServiceKey, Ge...
Script     1.0.1      Az.Monitor                          {Get-AzMetricDefinition, Get-AzMetric, Remove-AzLogProfile...
Script     1.2.1      Az.Network                          {Add-AzApplicationGatewayAuthenticationCertificate, Get-Az...
Script     1.0.0      Az.NotificationHubs                 {Get-AzNotificationHub, Get-AzNotificationHubAuthorization...
Script     1.1.0      Az.OperationalInsights              {New-AzOperationalInsightsAzureActivityLogDataSource, New-...
Script     1.0.0      Az.PolicyInsights                   {Get-AzPolicyEvent, Get-AzPolicyState, Get-AzPolicyStateSu...
Script     1.0.0      Az.PowerBIEmbedded                  {Remove-AzPowerBIWorkspaceCollection, Get-AzPowerBIWorkspa...
Script     1.0.1      Az.RecoveryServices                 {Get-AzRecoveryServicesBackupProperty, Get-AzRecoveryServi...
Script     1.0.0      Az.RedisCache                       {Remove-AzRedisCachePatchSchedule, New-AzRedisCacheSchedul...
Script     1.0.0      Az.Relay                            {New-AzRelayNamespace, Get-AzRelayNamespace, Set-AzRelayNa...
Script     1.1.3      Az.Resources                        {Get-AzProviderOperation, Remove-AzRoleAssignment, Get-AzR...
Script     1.0.0      Az.ServiceBus                       {New-AzServiceBusNamespace, Get-AzServiceBusNamespace, Set...
Script     1.0.1      Az.ServiceFabric                    {Add-AzServiceFabricApplicationCertificate, Add-AzServiceF...
Script     1.0.2      Az.SignalR                          {New-AzSignalR, Get-AzSignalR, Get-AzSignalRKey, New-AzSig...
Script     1.3.0      Az.Sql                              {Get-AzSqlDatabaseTransparentDataEncryption, Get-AzSqlData...
Script     1.0.2      Az.Storage                          {Get-AzStorageAccount, Get-AzStorageAccountKey, New-AzStor...
Script     1.0.0      Az.StreamAnalytics                  {Get-AzStreamAnalyticsFunction, Get-AzStreamAnalyticsDefau...
Script     1.0.1      Az.TrafficManager                   {Add-AzTrafficManagerCustomHeaderToEndpoint, Remove-AzTraf...
Script     1.1.1      Az.Websites                         {Get-AzAppServicePlan, Set-AzAppServicePlan, New-AzAppServ...

Debug output

DEBUG: 07:33:31 - ConnectAzureRmAccountCommand begin processing with ParameterSet 'UserWithCredential'.
DEBUG: 07:33:31 - Autosave setting from startup session: 'Process'
DEBUG: 07:33:31 - No autosave setting detected in environment variable 'AzContextAutoSave'. 
DEBUG: 07:33:31 - Using Autosave scope 'Process'
DEBUG: [ADAL]: Information: 12.03.2019 06:33:31:  - AuthenticationContext.cs: ADAL PCL.Desktop with assembly version '3.14.0.8', file version '3.14.40626.0546' and informational version 'b5589c8229ae45d2bc60b5d092ad34281d8ae537' is running...

DEBUG: [ADAL]: Information: 12.03.2019 06:33:31: f9ed99ce-4f16-4b02-a609-12ee611e368f - AcquireTokenHandlerBase.cs: === Token Acquisition started:
        Authority: https://login.microsoftonline.com/Common/
        Resource: https://management.core.windows.net/
        ClientId: 1950a258-227b-4e31-a9cf-717495945fc2
        CacheType: null
        Authentication Target: User


DEBUG: [ADAL]: Verbose: 12.03.2019 06:33:31: f9ed99ce-4f16-4b02-a609-12ee611e368f - TokenCache.cs: Looking up cache for a token...

DEBUG: [ADAL]: Information: 12.03.2019 06:33:31: f9ed99ce-4f16-4b02-a609-12ee611e368f - TokenCache.cs: No matching token was found in the cache

DEBUG: [ADAL]: Information: 12.03.2019 06:33:31: f9ed99ce-4f16-4b02-a609-12ee611e368f - UserRealmDiscoveryResponse.cs:  Sending user realm discovery request to 'https://login.microsoftonline.com/common/UserRealm/[UserMailAddress e.g. [email protected]]?api-version=1.0'

DEBUG: [ADAL]: Information: 12.03.2019 06:33:31: f9ed99ce-4f16-4b02-a609-12ee611e368f - AcquireTokenNonInteractiveHandler.cs:  User with hash 'pfa5jHaGNxlYXBBn+jqk3WavvxzIpR3hnKh5C0/vZwQ=' detected as 'Federated'
DEBUG: [ADAL]: Information: 12.03.2019 06:33:31: f9ed99ce-4f16-4b02-a609-12ee611e368f - AcquireTokenNonInteractiveHandler.cs:  WS-Trust endpoint 'https://[AdfsUrl]/adfs/services/trust/13/usernamemixed' fetched from MEX at 'https://[AdfsUrl]/adfs/services/trust/mex'

DEBUG: [ADAL]: Error: 12.03.2019 06:33:31: f9ed99ce-4f16-4b02-a609-12ee611e368f - AcquireTokenHandlerBase.cs: Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException: Federated service at https://[AdfsUrl]/adfs/services/trust/13/usernamemixed returned error: ID3035: The request was not valid or is malformed. ---> System.Net.Http.HttpRequestException:  Response status code does not indicate success: 500
(InternalServerError). ---> System.Exception: <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><s:Header><a:Action s:mustUnderstand="1">http://www.w3.org/2005/08/addressing/soap/fault</a:Action><a:RelatesTo>urn:uuid:ed33a773-d274-4bab-8498-a97dd1d5f2a5</a:RelatesTo><o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><u:Timestamp u:Id="_0"><u:Created>2019-03-12T06:33:31.720Z</u:Created><u:Expires>2019-03-12T06:38:31.720Z</u:Expires></u:Timestamp></o:Security></s:Header><s:Body><s:Fault><s:Code><s:Value>s:Sender</s:Value><s:Subcode><s:Value xmlns:a="http://docs.oasis-open.org/ws-sx/ws-trust/200512">a:InvalidRequest</s:Value></s:Subcode></s:Code><s:Reason><s:Text xml:lang="de-DE">ID3035: The request was not valid or is malformed.</s:Text></s:Reason></s:Fault></s:Body></s:Envelope>
   --- Ende der internen Ausnahmestapelüberwachung ---
   bei Microsoft.IdentityModel.Clients.ActiveDirectory.HttpClientWrapper.<GetResponseAsync>d__30.MoveNext()
   --- Ende der internen Ausnahmestapelüberwachung ---
   bei Microsoft.IdentityModel.Clients.ActiveDirectory.WsTrustRequest.<SendRequestAsync>d__3.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenNonInteractiveHandler.<PreTokenRequest>d__5.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenHandlerBase.<RunAsync>d__55.MoveNext()
        ErrorCode: federated_service_returned_error
        StatusCode: 500

Login-AzAccount : Federated service at https://[AdfsUrl]/adfs/services/trust/13/usernamemixed returned error: ID3035: The request was not valid or is malformed.
In [PowerShellScriptPathl].ps1:638 Zeichen:13
+             Login-AzAccount -Credential $userCred
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Connect-AzAccount], AdalServiceException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand
 
DEBUG: AzureQoSEvent: CommandName - Connect-AzAccount; IsSuccess - False; Duration - 00:00:00.5586647; Exception - Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException: Federated service at https://[AdfsUrl]/adfs/services/trust/13/usernamemixed returned error: ID3035: The request was not valid or is malformed. ---> System.Net.Http.HttpRequestException:  Response status code does not indicate success: 500 (InternalServerError). ---> System.Exception: <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><s:Header><a:Action s:mustUnderstand="1">http://www.w3.org/2005/08/addressing/soap/fault</a:Action><a:RelatesTo>urn:uuid:ed33a773-d274-4bab-8498-a97dd1d5f2a5</a:RelatesTo><o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><u:Timestamp u:Id="_0"><u:Created>2019-03-12T06:33:31.720Z</u:Created><u:Expires>2019-03-12T06:38:31.720Z</u:Expires></u:Timestamp></o:Security></s:Header><s:Body><s:Fault><s:Code><s:Value>s:Sender</s:Value><s:Subcode><s:Value xmlns:a="http://docs.oasis-open.org/ws-sx/ws-trust/200512">a:InvalidRequest</s:Value></s:Subcode></s:Code><s:Reason><s:Text xml:lang="de-DE">ID3035: The request was not valid or is malformed.</s:Text></s:Reason></s:Fault></s:Body></s:Envelope>
   --- Ende der internen Ausnahmestapelüberwachung ---
   bei Microsoft.IdentityModel.Clients.ActiveDirectory.HttpClientWrapper.<GetResponseAsync>d__30.MoveNext()
   --- Ende der internen Ausnahmestapelüberwachung ---
   bei Microsoft.IdentityModel.Clients.ActiveDirectory.WsTrustRequest.<SendRequestAsync>d__3.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenNonInteractiveHandler.<PreTokenRequest>d__5.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenHandlerBase.<RunAsync>d__55.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext.<AcquireTokenCommonAsync>d__52.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContextIntegratedAuthExtensions.<AcquireTokenAsync>d__0.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei Microsoft.Azure.PowerShell.Authenticators.AuthenticationResultToken.<GetAccessTokenAsync>d__11.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei Microsoft.Azure.Commands.Common.Authentication.Factories.AuthenticationFactory.Authenticate(IAzureAccount account, IAzureEnvironment environment, String tenant, SecureString password, String promptBehavior, Action`1 promptAction, IAzureTokenCache tokenCache, String resourceId)
   bei Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.AcquireAccessToken(IAzureAccount account, IAzureEnvironment environment, String tenantId, SecureString password, String promptBehavior, Action`1 promptAction)
   bei Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.ListAccountTenants(IAzureAccount account, IAzureEnvironment environment, SecureString password, String promptBehavior, Action`1 promptAction)   bei 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, Boolean shouldPopulateContextList)
   bei Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.<>c__DisplayClass92_0.<ExecuteCmdlet>b__0(AzureRmProfile localProfile, RMProfileClient profileClient, String name)
   bei Microsoft.Azure.Commands.Profile.Common.AzureContextModificationCmdlet.ModifyContext(Action`2 contextAction)
   bei Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.SetContextWithOverwritePrompt(Action`3 setContextAction)
   bei Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.ExecuteCmdlet()
   bei Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
        ErrorCode: federated_service_returned_error
        StatusCode: 500;
DEBUG: Finish sending metric.
DEBUG: 07:33:32 - ConnectAzureRmAccountCommand end processing.
DEBUG: 07:33:32 - ConnectAzureRmAccountCommand end processing.
[DBG]: PS [PathToPsScript]>
DEBUG: 07:33:36 - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.


   HistoryId: 13


Message        : Federated service at https://[AdfsUrl]/adfs/services/trust/13/usernamemixed returned error: ID3035: The request was not valid or is malformed.
StackTrace     :    bei Microsoft.IdentityModel.Clients.ActiveDirectory.WsTrustRequest.<SendRequestAsync>d__3.MoveNext()
                 --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
                    bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                    bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                    bei Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenNonInteractiveHandler.<PreTokenRequest>d__5.MoveNext()
                 --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
                    bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                    bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                    bei Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenHandlerBase.<RunAsync>d__55.MoveNext()
                 --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
                    bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                    bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                    bei Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext.<AcquireTokenCommonAsync>d__52.MoveNext()
                 --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
                    bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                    bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                    bei Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContextIntegratedAuthExtensions.<AcquireTokenAsync>d__0.MoveNext()
                 --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
                    bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                    bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                    bei Microsoft.Azure.PowerShell.Authenticators.AuthenticationResultToken.<GetAccessTokenAsync>d__11.MoveNext()
                 --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
                    bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                    bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                    bei Microsoft.Azure.Commands.Common.Authentication.Factories.AuthenticationFactory.Authenticate(IAzureAccount account, IAzureEnvironment environment, String tenant, SecureString password,
                 String promptBehavior, Action`1 promptAction, IAzureTokenCache tokenCache, String resourceId)
                    bei Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.AcquireAccessToken(IAzureAccount account, IAzureEnvironment environment, String tenantId, SecureString password, String
                 promptBehavior, Action`1 promptAction)
                    bei Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.ListAccountTenants(IAzureAccount account, IAzureEnvironment environment, SecureString password, String promptBehavior,
                 Action`1 promptAction)
                    bei 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, Boolean shouldPopulateContextList)
                    bei Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.<>c__DisplayClass92_0.<ExecuteCmdlet>b__0(AzureRmProfile localProfile, RMProfileClient profileClient, String name)
                    bei Microsoft.Azure.Commands.Profile.Common.AzureContextModificationCmdlet.ModifyContext(Action`2 contextAction)
                    bei Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.SetContextWithOverwritePrompt(Action`3 setContextAction)
                    bei Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.ExecuteCmdlet()
                    bei Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception      : Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException
InvocationInfo : {Connect-AzAccount}
Line           :             Login-AzAccount -Credential $userCred

Position       : In [PowerShellScriptPathl].ps1:638 Zeichen:13
                 +             Login-AzAccount -Credential $userCred
                 +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 13

Message        :  Response status code does not indicate success: 500 (InternalServerError).
StackTrace     :    bei Microsoft.IdentityModel.Clients.ActiveDirectory.HttpClientWrapper.<GetResponseAsync>d__30.MoveNext()
Exception      : System.Net.Http.HttpRequestException
InvocationInfo : {Connect-AzAccount}
Line           :             Login-AzAccount -Credential $userCred

Position       : In [PowerShellScriptPathl].ps1:638 Zeichen:13
                 +             Login-AzAccount -Credential $userCred
                 +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 13

Message        : <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"
                 xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><s:Header><a:Action
                 s:mustUnderstand="1">http://www.w3.org/2005/08/addressing/soap/fault</a:Action><a:RelatesTo>urn:uuid:ed33a773-d274-4bab-8498-a97dd1d5f2a5</a:RelatesTo><o:Security s:mustUnderstand="1"
                 xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><u:Timestamp u:Id="_0"><u:Created>2019-03-12T06:33:31.720Z</u:Created><u:Expires>2019-03-12T06:38:31.7
                 20Z</u:Expires></u:Timestamp></o:Security></s:Header><s:Body><s:Fault><s:Code><s:Value>s:Sender</s:Value><s:Subcode><s:Value
                 xmlns:a="http://docs.oasis-open.org/ws-sx/ws-trust/200512">a:InvalidRequest</s:Value></s:Subcode></s:Code><s:Reason><s:Text xml:lang="de-DE">ID3035: The request was not valid or is
                 malformed.</s:Text></s:Reason></s:Fault></s:Body></s:Envelope>
StackTrace     :
Exception      : System.Exception
InvocationInfo : {Connect-AzAccount}
Line           :             Login-AzAccount -Credential $userCred

Position       : In [PowerShellScriptPathl].ps1:638 Zeichen:13
                 +             Login-AzAccount -Credential $userCred
                 +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 13
	

DEBUG: AzureQoSEvent: CommandName - Resolve-AzError; IsSuccess - True; Duration - 00:00:00.1454206; Exception - ;
DEBUG: Finish sending metric.
DEBUG: 07:33:37 - ResolveError end processing.
DEBUG: 07:33:37 - ResolveError end processing.

Error output

07:45:34 - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.


   HistoryId: 13


Message        : Federated service at https://[AdfsUrl]/adfs/services/trust/13/usernamemixed returned error: ID3035: The request was not valid or is malformed.
StackTrace     :    bei Microsoft.IdentityModel.Clients.ActiveDirectory.WsTrustRequest.<SendRequestAsync>d__3.MoveNext()
                 --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
                    bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                    bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                    bei Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenNonInteractiveHandler.<PreTokenRequest>d__5.MoveNext()
                 --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
                    bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                    bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                    bei Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenHandlerBase.<RunAsync>d__55.MoveNext()
                 --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
                    bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                    bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                    bei Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext.<AcquireTokenCommonAsync>d__52.MoveNext()
                 --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
                    bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                    bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                    bei Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContextIntegratedAuthExtensions.<AcquireTokenAsync>d__0.MoveNext()
                 --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
                    bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                    bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                    bei Microsoft.Azure.PowerShell.Authenticators.AuthenticationResultToken.<GetAccessTokenAsync>d__11.MoveNext()
                 --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
                    bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                    bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                    bei Microsoft.Azure.Commands.Common.Authentication.Factories.AuthenticationFactory.Authenticate(IAzureAccount account, IAzureEnvironment environment, String tenant, SecureString password,
                 String promptBehavior, Action`1 promptAction, IAzureTokenCache tokenCache, String resourceId)
                    bei Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.AcquireAccessToken(IAzureAccount account, IAzureEnvironment environment, String tenantId, SecureString password, String
                 promptBehavior, Action`1 promptAction)
                    bei Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.ListAccountTenants(IAzureAccount account, IAzureEnvironment environment, SecureString password, String promptBehavior,
                 Action`1 promptAction)
                    bei 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, Boolean shouldPopulateContextList)
                    bei Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.<>c__DisplayClass92_0.<ExecuteCmdlet>b__0(AzureRmProfile localProfile, RMProfileClient profileClient, String name)
                    bei Microsoft.Azure.Commands.Profile.Common.AzureContextModificationCmdlet.ModifyContext(Action`2 contextAction)
                    bei Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.SetContextWithOverwritePrompt(Action`3 setContextAction)
                    bei Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.ExecuteCmdlet()
                    bei Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception      : Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException
InvocationInfo : {Connect-AzAccount}
Line           :             Login-AzAccount -Credential $userCred

Position       : In [PowerShellScriptPathl].ps1:638 Zeichen:13
                 +             Login-AzAccount -Credential $userCred
                 +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 13

Message        :  Response status code does not indicate success: 500 (InternalServerError).
StackTrace     :    bei Microsoft.IdentityModel.Clients.ActiveDirectory.HttpClientWrapper.<GetResponseAsync>d__30.MoveNext()
Exception      : System.Net.Http.HttpRequestException
InvocationInfo : {Connect-AzAccount}
Line           :             Login-AzAccount -Credential $userCred

Position       : In [PowerShellScriptPathl].ps1:638 Zeichen:13
                 +             Login-AzAccount -Credential $userCred
                 +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 13

Message        : <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"
                 xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><s:Header><a:Action
                 s:mustUnderstand="1">http://www.w3.org/2005/08/addressing/soap/fault</a:Action><a:RelatesTo>urn:uuid:ed33a773-d274-4bab-8498-a97dd1d5f2a5</a:RelatesTo><o:Security s:mustUnderstand="1"
                 xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><u:Timestamp u:Id="_0"><u:Created>2019-03-12T06:33:31.720Z</u:Created><u:Expires>2019-03-12T06:38:31.7
                 20Z</u:Expires></u:Timestamp></o:Security></s:Header><s:Body><s:Fault><s:Code><s:Value>s:Sender</s:Value><s:Subcode><s:Value
                 xmlns:a="http://docs.oasis-open.org/ws-sx/ws-trust/200512">a:InvalidRequest</s:Value></s:Subcode></s:Code><s:Reason><s:Text xml:lang="de-DE">ID3035: The request was not valid or is
                 malformed.</s:Text></s:Reason></s:Fault></s:Body></s:Envelope>
StackTrace     :
Exception      : System.Exception
InvocationInfo : {Connect-AzAccount}
Line           :             Login-AzAccount -Credential $userCred

Position       : In [PowerShellScriptPathl].ps1:638 Zeichen:13
                 +             Login-AzAccount -Credential $userCred
                 +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 13



AzureQoSEvent: CommandName - Resolve-AzError; IsSuccess - True; Duration - 00:00:00.0834664; Exception - ;
Finish sending metric.
07:45:34 - ResolveError end processing.
07:45:34 - ResolveError end processing.

sndkr avatar Mar 12 '19 06:03 sndkr

Same error, any workarounds ?

RobertoBorges avatar Mar 21 '19 16:03 RobertoBorges

@RobertoBorges Hello, no workarounf for this bug at the moment of my site. I hope of the next release.

sndkr avatar Mar 22 '19 08:03 sndkr

@RobertoBorges @sndkr This has to do with the underlying Trust connection with your local STS - this is the token service in your AD domain. Based on the error, this could be a configuration issue, or it could be soem issue with the request, for example that your directory does not allow user authentication without multi-factor auth. Forwarding this to the AD team, who may be able to help diagnose the local protocol issue in your domain.

markcowl avatar Mar 22 '19 19:03 markcowl

@sndkr So it looks like you are seeing this issue with username + Credential - are you also seeing it with interactive login (i.e. just running Connect-AzAccount, without parameters)?

The error indicates an issue with one of the initial protocol seteps with your eSTS, this coule be improperly url-encoding a special character in your password - if you're able to log in interactively, that would help to narrow the problem.

markcowl avatar Mar 25 '19 18:03 markcowl

Closing for lask of response in the last 10 days. Please reopen or open a new issue if this issue persists for you, and include the asked-for information.

markcowl avatar Apr 01 '19 16:04 markcowl

Install-Module -Name Az -Force -AllowClobber

worked for me

dhapolapankaj avatar Jul 18 '19 13:07 dhapolapankaj