I upgraded MassTransit to V7, and it seems there is a breaking change in connecting with Azure Service Bus. Previously, the code for creating an IBusControl
looked like this:
Bus.Factory.CreateUsingAzureServiceBus(cfg =>
{
cfg.Host(this.Host,
h =>
{
h.TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider(
"RootManageSharedAccessKey", this.AzureSharedAccessSignatureTokenKey);
});
...
This is not compiling anymore because the property TokenProvider
is no longer in IServiceBusHostConfigurator
.
What's the new way of providing the Service Bus access key?
The Azure SDK v7 uses TokenCredential
, which is the new way to specify credentials for all the various v7 SDKs. You can read about it in the documentation.
So for MassTransit, you'd set TokenCredential
to any of the supported credential types, e.g. DefaultAzureCredential
:
TokenCredential = new DefaultAzureCredential();