Azure / azure-webjobs-sdk

Azure WebJobs SDK
MIT License
739 stars 358 forks source link

How to use custom Azure Idenity token credential with JobHostConfiguration instead of connection string #3075

Open ShreyaMicrosft0306 opened 5 months ago

ShreyaMicrosft0306 commented 5 months ago

Please provide a succinct description of the issue.

How to use custom Azure Idenity token credential with JobHostConfiguration instead of connection string

Provide the steps required to reproduce the problem

JobHostConfiguration in Microsoft.Azure.WebJobs.Host var host=new JobHostConfiguration(_tableStorageConnectionString)

we are currently initializing host as above using tableStorageConnectionString but we want to leverage tokencredentials where we can authenticate using our first party app can you please help with how we can achieve that?

want to pass the token something like this Dependency injection with the Azure SDK for .NET - .NET | Microsoft Learn

Expected behavior

Unable to pass First party token to JobhostConfiguration

Actual behavior

Provide a description of the actual behavior observed.

Known workarounds

NA

Related information

Provide any related information

paulyuk commented 5 months ago

Hello. I think this sample will get you close: https://github.com/paulyuk/webjobs

Note how TokenCredential is set here, and I use the DefaultAzureCredential (the identity of the running process or host), but you could set it to something very specific. https://github.com/paulyuk/webjobs/blob/master/WebJob1/Program.cs#L41

magom001 commented 4 months ago

Sorry, but it is an awful experience. Environment variable? Magic settings names? Can we drop all of this and have a straight forward setup, where I tell this SDK which client to use or which authentication method to use?