MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.31k stars 21.49k forks source link

AzureFunctionsJobHost__extensions__durableTask__hubName #92760

Open lipalath-ms opened 2 years ago

lipalath-ms commented 2 years ago

Can I set hub name by adding a property 'AzureFunctionsJobHostextensionsdurableTask__hubName' in app setting rather than in host.json and adding DurableClient?


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

cgillum commented 2 years ago

@lipalath-ms can you clarify what you mean by "and adding DurableClient"?

lipalath-ms commented 2 years ago
[FunctionName("HttpStart")]
public static async Task<HttpResponseMessage> Run(
    [HttpTrigger(AuthorizationLevel.Function, methods: "post", Route = "orchestrators/{functionName}")] HttpRequestMessage req,
    [DurableClient(TaskHub = "%MyTaskHub%")] IDurableOrchestrationClient starter,
    string functionName,
    ILogger log)
{

}

As specified above - should we provide [DurableClient(TaskHub = "%MyTaskHub%")] IDurableOrchestrationClient starter?

This is how I specified in the code: [DurableClient] IDurableOrchestrationClient starter.

public async Task Run(
            [TimerTrigger("%schedule%")] TimerInfo myTimer,
            [DurableClient] IDurableOrchestrationClient starter,
            ILogger log)
        {

        }
cgillum commented 2 years ago

No, you should only define the task hub name in the [DurableClient] attribute when you want to use the client to target another function app. The default behavior is for the [DurableClient] binding to use the task hub value in host.json (which can be set using the app setting you referenced originally).

So going back to your original question, yes, you can use AzureFunctionsJobHost__extensions__durableTask__hubName to set the task hub value, but don't bother referencing it in [DurableClient]; it will be picked up automatically.

lipalath-ms commented 2 years ago

Thank you - for clarification I only want to add 'AzureFunctionsJobHostextensionsdurableTask__hubName ' property. no other changes are required to set hub name. Please confirm the same. Thanks!

cgillum commented 2 years ago

Yes, this is correct - no other changes are required.

lipalath-ms commented 2 years ago

Can this be mentioned in the doc (the doc doesn't mention anything about this property)