Closed davecader closed 1 year ago
//cc: @christothes
Thank you for your feedback. Tagging and routing to the team member best able to assist.
I attempted another approach using PublicClientApplicationBuilder instead of InteractiveBrowserCredential. I was able to successfully get an access token. I then encapsulated the access token and expiry in a custom TokenCredential implementation which was then used to initialize an ArmClient instance. So far so good.
Unfortunately, when using the client to interact with Azure (eg. AutomationCertificateResource.UpdateAsync) I again observe the InvalidOperation exception, this time with the message 'Response was not set, make sure SendAsync was called'. Get the same error with every Arure.ResourceManager.Automation method that I have called so far.
at Azure.Core.HttpMessage.get_Response()
at System.Diagnostics.DiagnosticSourceEventSource.TransformSpec.PropertySpec.PropertyFetch.TypedFetchProperty2.Fetch(Object obj) at System.Diagnostics.DiagnosticSourceEventSource.TransformSpec.Morph(Object obj) at System.Diagnostics.DiagnosticSourceEventSource.FilterAndTransform.Morph(Object args) at System.Diagnostics.DiagnosticSourceEventSource.FilterAndTransform.<>c__DisplayClass2_1.<.ctor>b__2(KeyValuePair
2 evnt)
at System.Diagnostics.DiagnosticSourceEventSource.CallbackObserver1.OnNext(T value) at System.Diagnostics.DiagnosticListener.Write(String name, Object value) at Azure.Core.Pipeline.DiagnosticScope.ActivityAdapter.Dispose() at Azure.Core.Pipeline.RequestActivityPolicy.<ProcessAsync>d__11.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Azure.Core.Pipeline.ResponseBodyPolicy.<ProcessAsync>d__5.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Azure.Core.Pipeline.BearerTokenAuthenticationPolicy.<ProcessAsync>d__11.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Azure.Core.Pipeline.RedirectPolicy.<ProcessAsync>d__5.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Azure.Core.Pipeline.RetryPolicy.<ProcessAsync>d__11.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Azure.Core.Pipeline.RetryPolicy.<ProcessAsync>d__11.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Azure.ResourceManager.Automation.RunbookRestOperations.<GetAsync>d__12.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Azure.ResourceManager.Automation.AutomationRunbookCollection.<GetAsync>d__7.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable
1.ConfiguredTaskAwaiter.GetResult()
at Kelverion.RunbookStudio.Cloud.Client.AutomationRunbookCollectionClient.1.ConfiguredTaskAwaiter.GetResult() at Kelverion.RunbookStudio.Cloud.Client.AutomationCollectionClientBase
1.
It looks like the exception is originating in Azure.Core/src/HttpMessage.cs at line 47. Not sure why it started to fail this week after working previously, but this is where the exception is thrown.
public Response Response
{
get
{
if (_response == null)
{
#pragma warning disable CA1065 // Do not raise exceptions in unexpected locations
throw new InvalidOperationException("Response was not set, make sure SendAsync was called");
#pragma warning restore CA1065 // Do not raise exceptions in unexpected locations
}
return _response;
}
set => _response = value;
}
Another interesting observation, is that this issue is only reproduceable when we debug our application in Visual Studio. When I run our application outside of the debugger, the error is not observed.
Hi @davecader - Would it be possible to provide a simplified code snippet that reproduces the problem?
After authenticating the ArmClient using Graph API (using the method discussed previously), I find that any call the the Azure SDK results in this error (it could be GetAll, Get, CreateOrUpdate, Patch - they all fail when running from Visual Studio). For example:
public async Task<IList<SubscriptionData>> ListAsync()
{
var result = new List<SubscriptionData>();
var enumerator = _subscriptions.GetAllAsync().GetAsyncEnumerator();
try
{
while (await enumerator.MoveNextAsync().ConfigureAwait(false))
{
var resource = enumerator.Current.Data;
result.Add(enumerator.Current.Data);
}
}
catch (RequestFailedException e)
{
throw new CloudOperationException(e.Message, e);
}
finally
{
await enumerator.DisposeAsync().ConfigureAwait(false);
}
return result;
}
Hi @davecader - I can't reproduce this using the code above. Could you enable logging and provide the output?
Hi, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!
Sorry, I've been out of the office. I will see if I can reproduce with logging enabled today.
Logging as requested:
[Informational] Azure-Identity: False MSAL 4.46.0.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-25 12:32:34Z - 57b5d182-5413-405b-b6d5-f69a623676aa]
=== Request Data ===
Authority Provided? - True
Scopes - https://management.azure.com//.default
Extra Query Params Keys (space separated) -
ApiId - AcquireTokenInteractive
IsConfidentialClient - False
SendX5C - False
LoginHint ? False
IsBrokerConfigured - False
HomeAccountId - False
CorrelationId - 57b5d182-5413-405b-b6d5-f69a623676aa
UserAssertion set: False
LongRunningOboCacheKey set: False
Region configured:
[Informational] Azure-Identity: False MSAL 4.46.0.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-25 12:32:34Z - 57b5d182-5413-405b-b6d5-f69a623676aa] === Token Acquisition (InteractiveRequest) started:
Scopes: https://management.azure.com//.default
Authority Host: login.microsoftonline.com
[Informational] Azure-Identity: False MSAL 4.46.0.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-25 12:32:34Z - 57b5d182-5413-405b-b6d5-f69a623676aa] [Region discovery] Not using a regional authority.
[Informational] Azure-Identity: False MSAL 4.46.0.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-25 12:32:34Z - 57b5d182-5413-405b-b6d5-f69a623676aa] Fetching instance discovery from the network from host login.microsoftonline.com.
[Informational] Azure-Core: Request [c6036818-a864-4e11-8380-f3e3b8676a3c] GET https://login.microsoftonline.com/common/discovery/instance?api-version=1.1&authorization_endpoint=REDACTED
x-client-SKU:REDACTED
x-client-Ver:REDACTED
x-client-CPU:REDACTED
x-client-OS:REDACTED
client-request-id:REDACTED
return-client-request-id:REDACTED
x-app-name:REDACTED
x-app-ver:REDACTED
x-ms-client-request-id:c6036818-a864-4e11-8380-f3e3b8676a3c
x-ms-return-client-request-id:true
User-Agent:azsdk-net-Identity/1.8.0 (.NET Framework 4.8.4515.0; Microsoft Windows 10.0.19045 )
client assembly: Azure.Identity
Exception thrown: 'System.InvalidOperationException' in Azure.Core.dll
Exception thrown: 'System.InvalidOperationException' in Azure.Core.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
[Informational] Azure-Core: Request [c6036818-a864-4e11-8380-f3e3b8676a3c] exception System.InvalidOperationException: Response was not set, make sure SendAsync was called
at Azure.Core.HttpMessage.get_Response()
at System.Diagnostics.DiagnosticSourceEventSource.TransformSpec.PropertySpec.PropertyFetch.TypedFetchProperty`2.Fetch(Object obj)
at System.Diagnostics.DiagnosticSourceEventSource.TransformSpec.PropertySpec.Fetch(Object obj)
at System.Diagnostics.DiagnosticSourceEventSource.TransformSpec.Morph(Object obj)
at System.Diagnostics.DiagnosticSourceEventSource.FilterAndTransform.Morph(Object args)
at System.Diagnostics.DiagnosticSourceEventSource.FilterAndTransform.<>c__DisplayClass2_1.<.ctor>b__2(KeyValuePair`2 evnt)
at System.Diagnostics.DiagnosticSourceEventSource.CallbackObserver`1.OnNext(T value)
at System.Diagnostics.DiagnosticListener.Write(String name, Object value)
at Azure.Core.Pipeline.DiagnosticScope.ActivityAdapter.Dispose()
at Azure.Core.Pipeline.DiagnosticScope.Dispose()
at Azure.Core.Pipeline.RequestActivityPolicy.<ProcessAsync>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Azure.Core.Pipeline.ResponseBodyPolicy.<ProcessAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Threading.Tasks.ValueTask.ThrowIfCompletedUnsuccessfully()
at Azure.Core.Pipeline.LoggingPolicy.<ProcessAsync>d__9.MoveNext()
Exception thrown: 'System.InvalidOperationException' in Azure.Core.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
[Error] Azure-Identity: False MSAL 4.46.0.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-25 12:32:36Z - 57b5d182-5413-405b-b6d5-f69a623676aa] === Token Acquisition (1005) failed.
Host: https://login.microsoftonline.com.
[Error] Azure-Identity: False MSAL 4.46.0.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-25 12:32:36Z - 57b5d182-5413-405b-b6d5-f69a623676aa] Exception type: System.InvalidOperationException
at Azure.Core.HttpMessage.get_Response()
at System.Diagnostics.DiagnosticSourceEventSource.TransformSpec.PropertySpec.PropertyFetch.TypedFetchProperty`2.Fetch(Object obj)
at System.Diagnostics.DiagnosticSourceEventSource.TransformSpec.PropertySpec.Fetch(Object obj)
at System.Diagnostics.DiagnosticSourceEventSource.TransformSpec.Morph(Object obj)
at System.Diagnostics.DiagnosticSourceEventSource.FilterAndTransform.Morph(Object args)
at System.Diagnostics.DiagnosticSourceEventSource.FilterAndTransform.<>c__DisplayClass2_1.<.ctor>b__2(KeyValuePair`2 evnt)
at System.Diagnostics.DiagnosticSourceEventSource.CallbackObserver`1.OnNext(T value)
at System.Diagnostics.DiagnosticListener.Write(String name, Object value)
at Azure.Core.Pipeline.DiagnosticScope.ActivityAdapter.Dispose()
at Azure.Core.Pipeline.DiagnosticScope.Dispose()
at Azure.Core.Pipeline.RequestActivityPolicy.<ProcessAsync>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Azure.Core.Pipeline.ResponseBodyPolicy.<ProcessAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Threading.Tasks.ValueTask.ThrowIfCompletedUnsuccessfully()
at Azure.Core.Pipeline.LoggingPolicy.<ProcessAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Azure.Core.Pipeline.RedirectPolicy.<ProcessAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Threading.Tasks.ValueTask.ThrowIfCompletedUnsuccessfully()
at Azure.Core.Pipeline.RetryPolicy.<ProcessAsync>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Azure.Core.Pipeline.RetryPolicy.<ProcessAsync>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Azure.Core.Pipeline.HttpPipeline.<SendRequestAsync>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Azure.Core.HttpPipelineMessageHandler.<SendAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.Http.HttpManager.<ExecuteAsync>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.Http.HttpManager.<ExecuteWithRetryAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.Http.HttpManager.<SendGetAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.Identity.Client.OAuth2.OAuth2Client.<ExecuteRequestAsync>d__11`1.MoveNext()
Exception thrown: 'System.InvalidOperationException' in Microsoft.Identity.Client.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
[Error] Azure-Identity: False MSAL 4.46.0.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-25 12:32:36Z - 57b5d182-5413-405b-b6d5-f69a623676aa] Exception type: System.InvalidOperationException
at Azure.Core.HttpMessage.get_Response()
at System.Diagnostics.DiagnosticSourceEventSource.TransformSpec.PropertySpec.PropertyFetch.TypedFetchProperty`2.Fetch(Object obj)
at System.Diagnostics.DiagnosticSourceEventSource.TransformSpec.PropertySpec.Fetch(Object obj)
at System.Diagnostics.DiagnosticSourceEventSource.TransformSpec.Morph(Object obj)
at System.Diagnostics.DiagnosticSourceEventSource.FilterAndTransform.Morph(Object args)
at System.Diagnostics.DiagnosticSourceEventSource.FilterAndTransform.<>c__DisplayClass2_1.<.ctor>b__2(KeyValuePair`2 evnt)
at System.Diagnostics.DiagnosticSourceEventSource.CallbackObserver`1.OnNext(T value)
at System.Diagnostics.DiagnosticListener.Write(String name, Object value)
at Azure.Core.Pipeline.DiagnosticScope.ActivityAdapter.Dispose()
at Azure.Core.Pipeline.DiagnosticScope.Dispose()
at Azure.Core.Pipeline.RequestActivityPolicy.<ProcessAsync>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Azure.Core.Pipeline.ResponseBodyPolicy.<ProcessAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Threading.Tasks.ValueTask.ThrowIfCompletedUnsuccessfully()
at Azure.Core.Pipeline.LoggingPolicy.<ProcessAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Azure.Core.Pipeline.RedirectPolicy.<ProcessAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Threading.Tasks.ValueTask.ThrowIfCompletedUnsuccessfully()
at Azure.Core.Pipeline.RetryPolicy.<ProcessAsync>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Azure.Core.Pipeline.RetryPolicy.<ProcessAsync>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Azure.Core.Pipeline.HttpPipeline.<SendRequestAsync>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Azure.Core.HttpPipelineMessageHandler.<SendAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.Http.HttpManager.<ExecuteAsync>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.Http.HttpManager.<ExecuteWithRetryAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.Http.HttpManager.<SendGetAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.Identity.Client.OAuth2.OAuth2Client.<ExecuteRequestAsync>d__11`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.OAuth2.OAuth2Client.<DiscoverAadInstanceAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.Instance.Discovery.NetworkMetadataProvider.<SendInstanceDiscoveryRequestAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.Instance.Discovery.NetworkMetadataProvider.<FetchAllDiscoveryMetadataAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.Instance.Discovery.NetworkMetadataProvider.<GetMetadataAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.Instance.Discovery.InstanceDiscoveryManager.<FetchNetworkMetadataOrFallbackAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.Instance.Discovery.InstanceDiscoveryManager.<GetMetadataEntryAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.Instance.AuthorityManager.<RunInstanceDiscoveryAndValidationAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.Internal.Requests.InteractiveRequest.<ExecuteAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.Internal.Requests.RequestBase.<RunAsync>d__12.MoveNext()
Exception thrown: 'System.InvalidOperationException' in Microsoft.Identity.Client.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
[Informational] Azure-Identity: InteractiveBrowserCredential.GetToken was unable to retrieve an access token. Scopes: [ https://management.azure.com//.default ] ParentRequestId: 5a204ceb-214a-4bf0-9d7c-5292fe393552 Exception: Azure.Identity.AuthenticationFailedException (0x80131500): InteractiveBrowserCredential authentication failed: Response was not set, make sure SendAsync was called
---> System.InvalidOperationException (0x80131509): Response was not set, make sure SendAsync was called
The parameters to the Event method do not match the parameters to the WriteEvent method. This may cause the event to be displayed incorrectly.
Exception thrown: 'Azure.Identity.AuthenticationFailedException' in Azure.Identity.dll
The parameters to the Event method do not match the parameters to the WriteEvent method. This may cause the event to be displayed incorrectly.
Exception thrown: 'Azure.Identity.AuthenticationFailedException' in mscorlib.dll
Exception thrown: 'Azure.Identity.AuthenticationFailedException' in mscorlib.dll
Exception thrown: 'Azure.Identity.AuthenticationFailedException' in mscorlib.dll
Exception thrown: 'Azure.Identity.AuthenticationFailedException' in mscorlib.dll
Exception thrown: 'Azure.Identity.AuthenticationFailedException' in mscorlib.dll
Exception thrown: 'Azure.Identity.AuthenticationFailedException' in mscorlib.dll
Exception thrown: 'Azure.Identity.AuthenticationFailedException' in mscorlib.dll
Exception thrown: 'Azure.Identity.AuthenticationFailedException' in mscorlib.dll
Exception thrown: 'Azure.Identity.AuthenticationFailedException' in mscorlib.dll
Exception thrown: 'Azure.Identity.AuthenticationFailedException' in mscorlib.dll
Exception thrown: 'Azure.Identity.AuthenticationFailedException' in mscorlib.dll
The parameters to the Event method do not match the parameters to the WriteEvent method. This may cause the event to be displayed incorrectly.
Exception thrown: 'Azure.Identity.AuthenticationFailedException' in Azure.ResourceManager.dll
The parameters to the Event method do not match the parameters to the WriteEvent method. This may cause the event to be displayed incorrectly.
Exception thrown: 'Azure.Identity.AuthenticationFailedException' in mscorlib.dll
Exception thrown: 'Azure.Identity.AuthenticationFailedException' in Microsoft.Bcl.AsyncInterfaces.dll
Exception thrown: 'Azure.Identity.AuthenticationFailedException' in mscorlib.dll
Exception thrown: 'Azure.Identity.AuthenticationFailedException' in Microsoft.Bcl.AsyncInterfaces.dll
Exception thrown: 'Azure.Identity.AuthenticationFailedException' in mscorlib.dll
This looks similar to https://github.com/dotnet/runtime/pull/49567 but that is only for .NET Core.
Would it be possible to create a sample project that reproduces this end to end? I suspect there is something about your specific project configuration or how you are configuring the credential that is key to reproducing this.
Yes, I can put something together. I also suspected project settings, given that it did not seem to be a commonly observed problem.
I have created this sample app that follows some of the MVVM patterns that we use in our larger application, including use of System.Reactive and ReactiveUI. You can clone the application using the following:
https://kelverion@dev.azure.com/kelverion/AzureAutomationClient/_git/AzureAutomationClient
I'm getting a similar exception in a net 4.8 project when using the KeyVault c# SDK. In my experiance it's only when a VS 2022 debugger is attached. I'm not seeing the error in production or when running locally without the debugger. At least so far.
Just thinking out loud here, but given the bug found and fixed in dot net core, could this be a Visual Studio induced error if it's using core?
Edit: I just noticed that bug was fixed in 2021, so I guess it would have likely shown up before now if it was VS.
As mentioned, I only observe the problem when I start our app in Visual Studio (2022 17.4.4). Interestingly, If I start our app normally and then start debugging in visual studio by attaching to the process I don't seem to observe the error.
I also am running 17.4.4 and have only recently noticed this issue happening, I can't remember exactly when I first noticed the issue or when I updated to 17.4.4 so I can't 100% say it was only having 17.4.4, but likely.
I'm running into a similar issue with .NET Framework 4.7.2 but Jetbrains Rider not Visual Studio (The same situation @fp-jcorriveau is in, other colleagues can use it fine in VS). Even if I start the process separately and attach Rider's debugger it still throws the exception:
System.InvalidOperationException: Response was not set, make sure SendAsync was called
at Azure.Core.HttpMessage.get_Response()
at System.Diagnostics.DiagnosticSourceEventSource.TransformSpec.PropertySpec.PropertyFetch.TypedFetchProperty`2.Fetch(Object obj)
at System.Diagnostics.DiagnosticSourceEventSource.TransformSpec.PropertySpec.Fetch(Object obj)
at System.Diagnostics.DiagnosticSourceEventSource.TransformSpec.Morph(Object obj)
at System.Diagnostics.DiagnosticSourceEventSource.FilterAndTransform.Morph(Object args)
at System.Diagnostics.DiagnosticSourceEventSource.FilterAndTransform.<>c__DisplayClass2_1.<.ctor>b__2(KeyValuePair`2 evnt)
at System.Diagnostics.DiagnosticSourceEventSource.CallbackObserver`1.OnNext(T value)
at System.Diagnostics.DiagnosticListener.Write(String name, Object value)
at Azure.Core.Pipeline.DiagnosticScope.ActivityAdapter.Dispose()
at Azure.Core.Pipeline.DiagnosticScope.Dispose()
at Azure.Core.Pipeline.RequestActivityPolicy.<ProcessAsync>d__11.MoveNext()
I'm running into a similar issue with .NET Framework 4.7.2 but Jetbrains Rider not Visual Studio (The same situation @fp-jcorriveau is in, other colleagues can use it fine in VS). Even if I start the process separately and attach Rider's debugger it still throws the exception:
System.InvalidOperationException: Response was not set, make sure SendAsync was called at Azure.Core.HttpMessage.get_Response() at System.Diagnostics.DiagnosticSourceEventSource.TransformSpec.PropertySpec.PropertyFetch.TypedFetchProperty`2.Fetch(Object obj) at System.Diagnostics.DiagnosticSourceEventSource.TransformSpec.PropertySpec.Fetch(Object obj) at System.Diagnostics.DiagnosticSourceEventSource.TransformSpec.Morph(Object obj) at System.Diagnostics.DiagnosticSourceEventSource.FilterAndTransform.Morph(Object args) at System.Diagnostics.DiagnosticSourceEventSource.FilterAndTransform.<>c__DisplayClass2_1.<.ctor>b__2(KeyValuePair`2 evnt) at System.Diagnostics.DiagnosticSourceEventSource.CallbackObserver`1.OnNext(T value) at System.Diagnostics.DiagnosticListener.Write(String name, Object value) at Azure.Core.Pipeline.DiagnosticScope.ActivityAdapter.Dispose() at Azure.Core.Pipeline.DiagnosticScope.Dispose() at Azure.Core.Pipeline.RequestActivityPolicy.<ProcessAsync>d__11.MoveNext()
Same error, same scenario
We're also seeing this across multiple developers using Rider:
Pretty sure this is happening because anything that reads properties for diagnostic purposes is going to end up triggering this exception when it does if it attempts to get diagnostics before the message is sent:
After lots of research, we may have narrowed this down to some of the Azure plugins attaching a DiagnosticSource
in Rider, but it does seem to happen even when those are off. I'm not surprised it's happening in Visual Studio too - it seems like this would be a general issue any time something has attached certain kinds of diagnostics, whatever host that may be. You can see the LoggingPolicy
getting in the mix in the stack trace.
IMO having the HttpMessage
throw like this in a getter seems like an anti-pattern. In general I think the guidance has always been to avoid throwing based on the state of the object inside a property whenever possible.
One possibly important data point is that we're running on .NET Core 3.1 right now. It looks like the DiagnosticSource
may have been changed to suppress these kinds of exceptions in properties in .NET 6 from the commit linked above: https://github.com/dotnet/runtime/pull/49567. I'm not in a position to update our runtime right now for this app, but I wonder if doing so would resolve the issue (or at least hide it), and if anyone reporting this problem is on >= .NET 6.
I solved this disabling Azure Devops plugin
I solved this disabling Azure Devops plugin
I don't use the Azure DevOps plugin, so it isn't installed for me. 😟
Tried if for some reason, installing it and then disabling it could fix it, but still no luck
For what it's worth, it looks like updating System.Diagnostics.DiagnosticSource
to 6.0.0 may have resolved this for us. That version is compatible with both older .NET Framework and .NET Core projects and includes the change in dotnet/runtime I linked above to suppress exceptions thrown by inspected properties. It's early still, so I can't say it's gone for good, but I was getting this exception regularly over the last few days and haven't seen it since the package change.
Of course, that doesn't mean the Azure SDK HttpMessage
isn't still throwing on inspection, just that the DiagnosticSource
isn't bubbling it up. Even with this "fix" I still think there's something left to look at in the Azure SDK.
For what it's worth, it looks like updating
System.Diagnostics.DiagnosticSource
to 6.0.0 may have resolved this for us. That version is compatible with both older .NET Framework and .NET Core projects and includes the change in dotnet/runtime I linked above to suppress exceptions thrown by inspected properties. It's early still, so I can't say it's gone for good, but I was getting this exception regularly over the last few days and haven't seen it since the package change.
Interesting, I'm going to try this. I'm also not using Azure DevOps plugin, but I have Azure Toolkit for Rider, I'll also try to disable it.
Disabling Azure Toolkit for Rider does nothing.
But updating System.Diagnostics.DiagnosticSource to 6.0.0 fixed the issue for me!
I'm actually experiencing a similar issue when I call the Exists()
on a BlobClient. Unlike some of the others who mentioned they are using Rider, I'm using Visual Studio Professional 2019, version 16.11.22. Sometimes it'll work, more often than not I'll get the exception.
Here's my function:
public bool BlobExists(string blobName, string connectionString, string containerName)
{
var container = new BlobContainerClient(connectionString, containerName);
var blobClient = container.GetBlobClient(blobName);
return blobClient.Exists();
}
Here's the exception:
System.InvalidOperationException: Response was not set, make sure SendAsync was called
at Azure.Core.HttpMessage.get_Response()
at System.Diagnostics.DiagnosticSourceEventSource.TransformSpec.PropertySpec.PropertyFetch.RefTypedFetchProperty`2.Fetch(Object obj)
at System.Diagnostics.DiagnosticSourceEventSource.TransformSpec.PropertySpec.Fetch(Object obj)
at System.Diagnostics.DiagnosticSourceEventSource.TransformSpec.Morph(Object obj)
at System.Diagnostics.DiagnosticSourceEventSource.FilterAndTransform.Morph(Object args)
at System.Diagnostics.DiagnosticSourceEventSource.FilterAndTransform.<>c__DisplayClass2_1.<.ctor>b__2(KeyValuePair`2 evnt)
at System.Diagnostics.DiagnosticSourceEventSource.CallbackObserver`1.OnNext(T value)
at System.Diagnostics.DiagnosticListener.Write(String name, Object value)
at System.Diagnostics.DiagnosticSource.StartActivity(Activity activity, Object args)
at Azure.Core.Pipeline.RequestActivityPolicy.ProcessAsync(HttpMessage message, ReadOnlyMemory`1 pipeline, Boolean isAsync)
at Azure.Core.Pipeline.TaskExtensions.EnsureCompleted(ValueTask task)
at Azure.Core.Pipeline.RequestActivityPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.BufferResponsePolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.LoggingPolicy.ProcessAsync(HttpMessage message, ReadOnlyMemory`1 pipeline, Boolean async)
at Azure.Core.Pipeline.TaskExtensions.EnsureCompleted(ValueTask task)
at Azure.Core.Pipeline.LoggingPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.HttpPipelineSynchronousPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.HttpPipelineSynchronousPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.RetryPolicy.ProcessAsync(HttpMessage message, ReadOnlyMemory`1 pipeline, Boolean async)
at Azure.Core.Pipeline.RetryPolicy.ProcessAsync(HttpMessage message, ReadOnlyMemory`1 pipeline, Boolean async)
at Azure.Core.Pipeline.TaskExtensions.EnsureCompleted(ValueTask task)
at Azure.Core.Pipeline.RetryPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.HttpPipelineSynchronousPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.HttpPipelineSynchronousPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.HttpPipeline.Send(HttpMessage message, CancellationToken cancellationToken)
at Azure.Storage.Blobs.BlobRestClient.Container.ListBlobsHierarchySegmentAsync(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri resourceUri, String version, String prefix, String delimiter, String marker, Nullable`1 maxresults, IEnumerable`1 include, Nullable`1 timeout, String requestId, Boolean async, String operationName, CancellationToken cancellationToken)
at Azure.Storage.Blobs.BlobContainerClient.GetBlobsByHierarchyInternal(String marker, String delimiter, BlobTraits traits, BlobStates states, String prefix, Nullable`1 pageSizeHint, Boolean async, CancellationToken cancellationToken)
at Azure.Storage.TaskExtensions.EnsureCompleted[T](Task`1 task)
at Azure.Storage.Blobs.Models.GetBlobsByHierarchyAsyncCollection.GetNextPageAsync(String continuationToken, Nullable`1 pageSizeHint, Boolean isAsync, CancellationToken cancellationToken)
at Azure.Storage.TaskExtensions.EnsureCompleted[T](ValueTask`1 task)
at Azure.Storage.StorageCollectionEnumerator`1.StoragePageable.AsPages(String continuationToken, Nullable`1 pageHintSize)+MoveNext()
at LessonDesignerApi.Services.BlobService.EnumerateBlobsHelper(String strBlobPathPrefix) in F:\Programming\Work\Tools\lessondesignerasssetmigrationtool - Copy\LessonDesignerAssetMigrationTool\BlobService.cs:line 228
at LessonDesignerApi.Services.BlobService.EnumerateBlobs(String strBlobPathPrefix) in F:\Programming\Work\Tools\lessondesignerasssetmigrationtool - Copy\LessonDesignerAssetMigrationTool\BlobService.cs:line 218
at LessonDesignerAssetMigrationTool.Program.UploadReferenceBlobsFromRoot(String rootReferenceSourceUrl, String rootTargetUrl, IBlobService referenceBlobService, IBlobService targetBlobService) in F:\Programming\Work\Tools\lessondesignerasssetmigrationtool - Copy\LessonDesignerAssetMigrationTool\Program.cs:line 561
at LessonDesignerAssetMigrationTool.Program.UploadNonSeededAsset(BlobReference blobReference, IBlobService targetBlobService, IBlobService referenceBlobService) in F:\Programming\Work\Tools\lessondesignerasssetmigrationtool - Copy\LessonDesignerAssetMigrationTool\Program.cs:line 399
at LessonDesignerAssetMigrationTool.Program.<>c__DisplayClass18_0.<<CreateDbInformationAndUpdateReference>b__0>d.MoveNext() in F:\Programming\Work\Tools\lessondesignerasssetmigrationtool - Copy\LessonDesignerAssetMigrationTool\Program.cs:line 521
--- End of stack trace from previous location where exception was thrown ---
We're also having this problem with .NET Core 3.1 with 2 projects. We temporarily upgraded it to .NET 6 which seems to be solving it. (I know not the best solution)
I have experienced this problem after updating ReSharper for VisualStudio 2022 to version 2022.3. Fortunately, I've been able to work around it by downgrading ReSharper to version 2022.2. https://www.jetbrains.com/resharper/download/other.html
I had a similar problem to @PiousVenom with blobClient.Exists(). After months of working, this suddenly started giving "Response was not set, make sure SendAsync' was called " errors, unpredictably, on blobs that definitely existed, but only when running in debug.
In our case, the problem was fixed by upgrading the code (written using .net Framework 4.72 for some reason rather than .NET 5 or later) to .net framework 4.8, Hope this helps in solving this very strange problem!
Also seeing this whilst debugging in Rider using .net core 3.1. Live appears to be fine. This is affecting 3 developers here intermittently. It seems you can go a large time without seeing it and then a stretch where it always happens. Again only noticed it over the last 2 or 3 weeks.
Updayting System.Diagnostics.DiagnosticSource to 6.0.0 seems to be the resolution here. The fix is here https://github.com/dotnet/runtime/pull/49567
Hi @davecader. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve
” to remove the “issue-addressed” label and continue the conversation.
Updating to latest System.Diagnostics.DiagnosticSource appears to have resolved my issue. Thanks for the help everyone.
Hi blackf0rk, only the original author of the issue can ask that it be unresolved. Please open a new issue with your scenario and details if you would like to discuss this topic with the team.
Hi blackf0rk, only the original author of the issue can ask that it be unresolved. Please open a new issue with your scenario and details if you would like to discuss this topic with the team.
Library name and version
Azure.ResourceManager 1.3.1
Describe the bug
We are observing an 'Authentication failed: Response was not set, make sure SendAsync' was called when attempting to authenticate with Azure. We first starting noticing this error on 2023-01-04 (it was authenticating without error previously).
Call Stack:
at Azure.Identity.CredentialDiagnosticScope.FailWrapAndThrow(Exception ex, String additionalMessage)d39.MoveNext()d 36.MoveNext()d34.MoveNext()d 4.MoveNext()
at Azure.Identity.InteractiveBrowserCredential.
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Azure.Identity.InteractiveBrowserCredential.
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Azure.Identity.InteractiveBrowserCredential.
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() t Kelverion.RunbookStudio.Cloud.Client.AutomationClientFactory.
Expected behavior
Should authenticate without error.
Actual behavior
Authentication fails with InvalidOperationException ''InteractiveBrowserCredential authentication failed: Response was not set, make sure SendAsync' exception.
Reproduction Steps
var options = new InteractiveBrowserCredentialOptions { ... } var credential = new InteractiveBrowserCredential(options); await credential.AuthenticateAsync();
Environment
.NET Framework 4.8.1 Windows 10