Azure Durable Functions: passing storage connection string based on tenant id, how to do this

135 Views Asked by At

I'm trying to create a durable function that takes a different connection string based on the tenant that is initiating the durable function.

The approach I've been trying to figure out uses the built-in attribute parameters but I haven't found a way to dynamically pass in the connection string. That code looks like

    [FunctionName("Function1_HttpStart2")]
    public static async Task<HttpResponseMessage> HttpStart2(
    [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestMessage req,
    [DurableClient(ConnectionName = x)] IDurableOrchestrationClient starter,
    ILogger log)
    {

Is there a way to pass variable "x" into the attribute? Or is there another way to create the IDurableOrchestrationClient bound to the connection?

I looked at newing up a DurableOrchestrationClient using the extensions package but it doesn't recognize that type. So, I went back to see if passing data into the attribute would work.

So far nothing has worked.

Appreciate the assistance

1

There are 1 best solutions below

2
On

Based on the implementation, looks like the ConnectionName is the only option.

You could have to create app setting entries for each tenant you have or I suppose a better solution would be to setup a custom configuration source like Azure App Configuration to store various connection strings.