I made it work by adding <CONNECTION_NAME_PREFIX>__credential and <CONNECTION_NAME_PREFIX>__clientId mentioned in this document learn.microsoft.com/en-us/azure/azure-functions/…
Azure Functions can't load the proper managed identity to receive message from Service Bus
I made the change based on this instruction to use managed identity to receive message from service bus https://learn.microsoft.com/en-us/azure/azure-functions/functions-identity-based-connections-tutorial-2, but seeing errors of "Unable to load the proper Managed Identity."
Here is what I did for the configuration:
- Added ServiceBusConnection__fullyQualifiedNamespace and was able to see it in the error log.
- Assigned managed identity (Azure Function) role of Azure Service Bus Data Receiver in Service Bus namespace.
- In the function trigger in code, added [ServiceBusTrigger("mytopic", "mysub", Connection = "ServiceBusConnection")
The error is
mytopic/Subscriptions/mysub-xxx: ReceiveBatchAsync Exception: Azure.Identity.AuthenticationFailedException: ManagedIdentityCredential authentication failed: Service request failed. Status: 400 (Bad Request)
Content: {"statusCode":400,"message":"Unable to load the proper Managed Identity.","correlationId":"xxx..."}
at Azure.Identity.ManagedIdentitySource.HandleResponseAsync(Boolean async, TokenRequestContext context, HttpMessage message, CancellationToken cancellationToken) at Azure.Identity.ManagedIdentitySource.AuthenticateAsync(Boolean async, TokenRequestContext context, CancellationToken cancellationToken) at Azure.Identity.ManagedIdentityClient.AuthenticateCoreAsync(Boolean async, TokenRequestContext context, CancellationToken cancellationToken) at Azure.Identity.ManagedIdentityClient.AppTokenProviderImpl(AppTokenProviderParameters parameters) at Microsoft.Identity.Client.Internal.Requests.ClientCredentialRequest.SendTokenRequestToAppTokenProviderAsync(ILoggerAdapter logger, CancellationToken cancellationToken) at Microsoft.Identity.Client.Internal.Requests.ClientCredentialRequest.GetAccessTokenAsync(CancellationToken cancellationToken, ILoggerAdapter logger) at Microsoft.Identity.Client.Internal.Requests.ClientCredentialRequest.ExecuteAsync(CancellationToken cancellationToken) at Microsoft.Identity.Client.Internal.Requests.RequestBase.<>c__DisplayClass11_1.<
1 answer
Sort by: Most helpful
-
Yifan Du 75 Reputation points Microsoft Employee
2025-02-03T15:23:40.0133333+00:00