'Cannot connect Mass Transit to a Managed Identity in an Azure Function
I am trying to configure Mass Transit to allow me to use a User Assigned Managed Identity instead of needing to store the connection string in the local settings of my Azure Function.
I have gathered there is a secondary parameter that should be used to achieve this on the AddMassTransitForAzureFunctions method. I have done this below:
builder.Services.AddMassTransitForAzureFunctions(cfg =>
{
cfg.AddConsumersFromNamespaceContaining<ConsumerNamespace>();
}, "ServiceBus", (context, configurator) =>
{
string clientId = Environment.GetEnvironmentVariable(CommonConstants.ConfigSettingsKeys.ManagedIdentityClientId);
var settings = new HostSettings
{
ServiceUri = new Uri("sb://mytestservicebus.servicebus.windows.net"),
TokenCredential = new DefaultAzureCredential(new DefaultAzureCredentialOptions { ManagedIdentityClientId = clientId })
};
configurator.Host(settings);
});
The problem is that the code passed in for the first parameter gets called, but the code that gets passed in to get excecuted as the final paramter never gets called. Is there something else I need to set here to make sure the code gets called?
I am using version 7.3.1 of Mass Transit.
Thank you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
