Skip to content

Commit f21a153

Browse files
committed
Do not use DefaultAzureCredential, use a chain of methods to try first ManagedIdentity, then environment and afterwards Az CLI (for development environments)
1 parent c9981eb commit f21a153

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

dotnet/src/dotnetcore/Providers/Messaging/GXAzureServiceBus/AzureServiceBus.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ private void Initialize(GXService providerService)
6565
//https://docs.microsoft.com/en-us/javascript/api/@azure/service-bus/servicebusclientoptions?view=azure-node-latest#@azure-service-bus-servicebusclientoptions-websocketoptions
6666

6767
if (authenticationMethod.Equals(AuthenticationMethod.ActiveDirectory.ToString()))
68-
{
69-
_serviceBusClient = new ServiceBusClient(_fullyqualifiedNamespace, new DefaultAzureCredential());
68+
{
69+
ChainedTokenCredential credential = new ChainedTokenCredential(new ManagedIdentityCredential(), new EnvironmentCredential(), new AzureCliCredential());
70+
_serviceBusClient = new ServiceBusClient(_fullyqualifiedNamespace, credential);
7071
GXLogging.Debug(logger, "Authenticate to Azure Service Bus using Active Directory authentication.");
7172
}
7273
else

0 commit comments

Comments
 (0)