简体   繁体   中英

Is it possible to use Managed Identity authentication with .NET Framework web jobs?

My team recently upgraded our .netcore components to use Managed Identities to authenticate with Azure Service Bus.

services.AddAzureClients(builder =>
    {
        var credential = new DefaultAzureCredential(new DefaultAzureCredentialOptions
        {
            ManagedIdentityClientId = clientId
        });
   });

We've been asked to upgrade our legacy .NET Framework 4.7.2 web jobs (SDK 2.0) to also use Managed Identities.

Does anyone know if it is possible to use Managed Identities with .NET Framework web jobs and their JobHot(JobHostingConfiguration) start up code?, or would we need to migrate our components to .netcore?

We have a road map to upgrade our .NET Framework components in the future, but I'm wondering if we need to fast track the upgrade if we want to use Managed Identities.

Any advice would be much appreciated.

I think I figured it out. I needed to install/upgrade the following packages to use the WebJobs SDK 3.0.

  1. Microsoft.Azure.WebJobs(>= 3.0.10)
  2. Microsoft.Azure.WebJobs.Extensions
  3. Microsoft.Azure.WebJobs.Extensions.ServiceBus
  4. Microsoft.Azure.WebJobs.ServiceBus

This should allow me to auto-bind the ServiceBusTrigger using the Connection property.

public static void ProcessMessage(
    [ServiceBusTrigger("test", Connection = "ServiceBusConnection")]string myQueueItem,
    ILogger log)
    {
        log.LogInformation(myQueueItem);
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM