Skip to content

Support for managed identity w/o conn string? #110

@anyeone

Description

@anyeone

Hi,

I'm in the process of evaluating Rebus for our platform. I have several years of experience developing sagas with NServiceBus so am very familiar with the concepts.

Have you considered adding support for initializing the AzureServiceBusTransport with a managed identity + credential or a ServiceBusClientFactory method in addition to a connection string? As you probably are aware, the practice of using connection strings to connect to Azure resources is not ideal anymore and AzureServiceBus itself supports initializing a client from just a uri + a credential as such:

new ServiceBusClient(serviceBusClientUri, credential);

For example, here's how I register ASB with one of my applications in the DI container today:
` builder.Services.AddScoped(sb =>
{
if (sbConfig == null || string.IsNullOrEmpty(sbConfig.ServiceBusClientUri))
{
throw new ConfigurationErrorsException("Missing 'CleanupServiceConfiguration:*' settings from App Config.");
}

        var credential = new DefaultAzureCredential();
        return new ServiceBusClient(sbConfig.ServiceBusClientUri, credential);
    });`

It seems like it shouldn't be a huge stretch to overload the constructor for AzureServiceBusTransport to accept a ServiceBusClientFactory method that knows how to generate a credential, and then to have the Rebus framework use that ServiceBusClientFactory to get a client when necessary (we wouldn't want to initialize with a credential instance since it would of course eventually expire, hence the factory instead).

Is this something you'd be interested in doing or accepting a PR about? I don't want to commit to doing a PR just yet but if after evaluating Rebus we want to use it, we definitely would want to avoid having to use connection strings.

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions