5

I'm trying to connect to an Azure Service Bus and I'm facing an issue. It seems impossible to connect as I always get this error:

Azure.Identity.AuthenticationFailedException: ClientSecretCredential authentication failed: Response was not set, make sure SendAsync was called

Here is a code snippet of what I'm trying to do

var adminClient = new ServiceBusAdministrationClient(
    mySettings.AzureServiceBus.Endpoint,
    new ClientSecretCredential(mySettings.AzureServiceBus.TenantId,
        mySettings.AzureServiceBus.ClientId, mySettings.AzureServiceBus.ClientSecret));

var exists = await adminClient.SubscriptionExistsAsync(myTopic, mySubName).ConfigureAwait(false); 

Diagnostics from AzureEventSourceListener:

[Informational] Azure-Identity: ClientSecretCredential.GetToken invoked. Scopes: [ https://servicebus.azure.net/.default ] ParentRequestId: 8cd8075d-fb77-4479-bf12-d612fff0de99
[Informational] Azure-Identity: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [02/01/2023 23:46:30 - ] MSAL MSAL.Desktop with assembly version '4.30.1.0'. CorrelationId(e1994990-3e32-43b9-83e5-55a325de668a)
[Informational] Azure-Identity: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [02/01/2023 23:46:30 - ] === AcquireTokenForClientParameters ===
SendX5C: False
ForceRefresh: False

[Informational] Azure-Identity: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [02/01/2023 23:46:30 - ]
=== Request Data ===
Authority Provided? - True
Scopes - https://servicebus.azure.net/.default
Extra Query Params Keys (space separated) -
ApiId - AcquireTokenForClient
IsConfidentialClient - True
SendX5C - False
LoginHint ? False
IsBrokerConfigured - False
HomeAccountId - False
CorrelationId - e1994990-3e32-43b9-83e5-55a325de668a

[Informational] Azure-Identity: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [02/01/2023 23:46:30 - ] === Token Acquisition (ClientCredentialRequest) started:

    Authority Host: login.microsoftonline.com
[Informational] Azure-Identity: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [02/01/2023 23:46:30 - ] Azure region was not configured or could not be discovered. Not using a regional authority.
[Informational] Azure-Identity: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [02/01/2023 23:46:30 - ] Azure region was not configured or could not be discovered. Not using a regional authority.
[Informational] Azure-Identity: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [02/01/2023 23:46:30 - ] Fetching instance discovery from the network from host login.microsoftonline.com.
[Informational] Azure-Core: Request [76254b44-7f17-42bc-9810-ae56aab73c66] GET https://login.microsoftonline.com/common/discovery/instance?api-version=REDACTED&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:REDACTED
x-ms-return-client-request-id:REDACTED
User-Agent:REDACTED
client assembly: Azure.Identity
[Informational] Azure-Core: Request [76254b44-7f17-42bc-9810-ae56aab73c66] exception System.InvalidOperationException: Response was not set, make sure SendAsync was called
à Azure.Core.HttpMessage.get_Response()
à System.Diagnostics.DiagnosticSourceEventSource.TransformSpec.PropertySpec.PropertyFetch.RefTypedFetchProperty2.Fetch(Object obj) à System.Diagnostics.DiagnosticSourceEventSource.TransformSpec.PropertySpec.Fetch(Object obj) à System.Diagnostics.DiagnosticSourceEventSource.TransformSpec.Morph(Object obj) à System.Diagnostics.DiagnosticSourceEventSource.FilterAndTransform.Morph(Object args) à System.Diagnostics.DiagnosticSourceEventSource.FilterAndTransform.<>c__DisplayClass2_1.<.ctor>b__2(KeyValuePair2 evnt)
à System.Diagnostics.DiagnosticSourceEventSource.CallbackObserver`1.OnNext(T value)
à System.Diagnostics.DiagnosticListener.Write(String name, Object value)
à Azure.Core.Pipeline.DiagnosticScope.ActivityAdapter.Dispose()
à Azure.Core.Pipeline.DiagnosticScope.Dispose()
à Azure.Core.Pipeline.RequestActivityPolicy.d__11.MoveNext()
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
à System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable.ConfiguredValueTaskAwaiter.GetResult()
à Azure.Core.Pipeline.ResponseBodyPolicy.d__5.MoveNext()
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
à System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable.ConfiguredValueTaskAwaiter.GetResult()
à Azure.Core.Pipeline.LoggingPolicy.d__9.MoveNext()
[Error] Azure-Identity: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [02/01/2023 23:46:30 - ] Exception type: System.InvalidOperationException

à Azure.Core.HttpMessage.get_Response()
à System.Diagnostics.DiagnosticSourceEventSource.TransformSpec.PropertySpec.PropertyFetch.RefTypedFetchProperty2.Fetch(Object obj) à System.Diagnostics.DiagnosticSourceEventSource.TransformSpec.PropertySpec.Fetch(Object obj) à System.Diagnostics.DiagnosticSourceEventSource.TransformSpec.Morph(Object obj) à System.Diagnostics.DiagnosticSourceEventSource.FilterAndTransform.Morph(Object args) à System.Diagnostics.DiagnosticSourceEventSource.FilterAndTransform.<>c__DisplayClass2_1.<.ctor>b__2(KeyValuePair2 evnt)
à System.Diagnostics.DiagnosticSourceEventSource.CallbackObserver1.OnNext(T value) à System.Diagnostics.DiagnosticListener.Write(String name, Object value) à Azure.Core.Pipeline.DiagnosticScope.ActivityAdapter.Dispose() à Azure.Core.Pipeline.DiagnosticScope.Dispose() à Azure.Core.Pipeline.RequestActivityPolicy.<ProcessAsync>d__11.MoveNext() --- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée --- à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) à System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable.ConfiguredValueTaskAwaiter.GetResult() à Azure.Core.Pipeline.ResponseBodyPolicy.<ProcessAsync>d__5.MoveNext() --- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée --- à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) à System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable.ConfiguredValueTaskAwaiter.GetResult() à Azure.Core.Pipeline.LoggingPolicy.<ProcessAsync>d__9.MoveNext() --- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée --- à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) à System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable.ConfiguredValueTaskAwaiter.GetResult() à Azure.Core.Pipeline.RedirectPolicy.<ProcessAsync>d__5.MoveNext() --- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée --- à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) à System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable.ConfiguredValueTaskAwaiter.GetResult() à Azure.Core.Pipeline.RetryPolicy.<ProcessAsync>d__11.MoveNext() --- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée --- à System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() à Azure.Core.Pipeline.RetryPolicy.<ProcessAsync>d__11.MoveNext() --- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée --- à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) à System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable.ConfiguredValueTaskAwaiter.GetResult() à Azure.Core.Pipeline.HttpPipeline.<SendRequestAsync>d__11.MoveNext() --- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée --- à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) à System.Threading.Tasks.ValueTask1.get_Result()
à System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable1.ConfiguredValueTaskAwaiter.GetResult() à Azure.Core.HttpPipelineMessageHandler.<SendAsync>d__2.MoveNext() --- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée --- à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) à System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
à System.Net.Http.HttpClient.d__58.MoveNext()
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
à System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() à Microsoft.Identity.Client.Http.HttpManager.<ExecuteAsync>d__10.MoveNext() --- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée --- à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) à System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
à Microsoft.Identity.Client.Http.HttpManager.d__8.MoveNext()
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
à System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() à Microsoft.Identity.Client.Http.HttpManager.<SendGetAsync>d__5.MoveNext() --- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée --- à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) à System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
à Microsoft.Identity.Client.OAuth2.OAuth2Client.d__111.MoveNext() --- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée --- à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) à System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
à Microsoft.Identity.Client.OAuth2.OAuth2Client.d__9.MoveNext()
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
à System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() à Microsoft.Identity.Client.Instance.Discovery.NetworkMetadataProvider.<SendInstanceDiscoveryRequestAsync>d__7.MoveNext() --- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée --- à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) à System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
à Microsoft.Identity.Client.Instance.Discovery.NetworkMetadataProvider.d__6.MoveNext()
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
à System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() à Microsoft.Identity.Client.Instance.Discovery.NetworkMetadataProvider.<GetMetadataAsync>d__4.MoveNext() --- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée --- à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) à System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
à Microsoft.Identity.Client.Instance.Discovery.InstanceDiscoveryManager.d__10.MoveNext()
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
à System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() à Microsoft.Identity.Client.Instance.Discovery.InstanceDiscoveryManager.<GetMetadataEntryAsync>d__9.MoveNext() --- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée --- à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) à System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
à Microsoft.Identity.Client.Instance.AuthorityManager.d__9.MoveNext()
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
à System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
à Microsoft.Identity.Client.Internal.Requests.ClientCredentialRequest.d__3.MoveNext()
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
à System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() à Microsoft.Identity.Client.Internal.Requests.ClientCredentialRequest.<ExecuteAsync>d__2.MoveNext() --- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée --- à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) à System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
à Microsoft.Identity.Client.Internal.Requests.RequestBase.d__13.MoveNext()
[Informational] Azure-Identity: ClientSecretCredential.GetToken was unable to retrieve an access token. Scopes: [ https://servicebus.azure.net/.default ] ParentRequestId: 8cd8075d-fb77-4479-bf12-d612fff0de99 Exception: Azure.Iden
tity.AuthenticationFailedException (0x80131500): ClientSecretCredential authentication failed: Response was not set, make sure SendAsync was called
---> System.InvalidOperationException (0x80131509): Response was not set, make sure SendAsync was called

Day to day I'm using Jetbrains Rider on Win 11. It fails everytime. Strangely I managed to make it work after navigating through the client properties in the debugger. I can't say what properties, if it forced evaluating something, but I made it works, not everytime.

I asked a collegue of mine to try it, he's using Visual Studio and it never fails. So I installed VStudio Community to give it a try, and... it works... Cannot explain the difference.

2
  • There's an issue open for this scenario for which discussion is still ongoing. I'd suggest joining the conversation there, as we've been unable to reproduce this for investigation and your perspective may prove helpful. github.com/Azure/azure-sdk-for-net/issues/33294 Commented Feb 4, 2023 at 15:06
  • Thanks, I'm already following this! Commented Feb 13, 2023 at 13:38

2 Answers 2

6

Try updating System.Diagnostics.DiagnosticSource to version 6.0.0.

This appears to have been fixed by this PR

1
  • What if we are targeting an older framework? Those packages are installable but not tested with netcoreapp3.1 for instance. Not sure if we can update the runtime right now and I think I am getting some strange performance issues when using the 7.0.1 of that diagnostics package. Commented Mar 2, 2023 at 18:45
0

We got the same issue. The fix for us is running VS in admin mode.

Not the answer you're looking for? Browse other questions tagged or ask your own question.