Azure Functions can't load the proper managed identity to receive message from Service Bus

Yifan Du 15 Reputation points Microsoft Employee
2024-06-26T16:43:33.3933333+00:00

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:

  1. Added ServiceBusConnection__fullyQualifiedNamespace and was able to see it in the error log.
  2. Assigned managed identity (Azure Function) role of Azure Service Bus Data Receiver in Service Bus namespace.
  3. 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.<

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,542 questions
0 comments No comments
{count} votes