azure-functions-durable-extension: Task Hub name must be specified in host.json when using slots
Describe the bug
When I deploy a Durable Functions App to Function App, it said
The function runtime is unable to start. Microsoft.Azure.WebJobs.Extensions.DurableTask: Task Hub name must be specified in host.json when using slots.
Investigative information
Durable Functions extension version: 2.0.0 Function App version (1.0 or 2.0): 2.0 Programming language used: C#
My host.json file content:
{
"version": "2.0",
"extensions": {
"durableTask": {
"hubName": "%SlotTaskHub%"
}
}
}
My settings.json (main slot):
{
"IsEncrypted": false,
"Values": {
"SlotTaskHub": "MainHubName"
}
}
My settings.json (dev slot):
{
"IsEncrypted": false,
"Values": {
"SlotTaskHub": "DevHubName"
}
}
My client function:
[FunctionName("MyFunctionName")]
public async Task<HttpResponseMessage> MyFunctionAsync([HttpTrigger(AuthorizationLevel.Anonymous, "POST")]HttpRequestMessage request,
[DurableClient(TaskHub = "%SlotTaskHub%")]IDurableOrchestrationClient starter)
{
//My code here
}
Expected behavior Successfully works in both slots with different TaskHub names and the same storage account.
Actual behavior If deployed to the main slot, it works. If deployed to other slots, I receive the error.
Additional context
- Development environment (ex. Visual Studio) Visual Studio 2019
- Additional bindings used HttpTrigger or ServiceBusTrigger
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 23 (10 by maintainers)
It should also be possible to omit
hubName
from host.json and set the hub name with an app setting calledAzureFunctionsJobHost__extensions__durableTask__hubName
. It works in a production slot (can confirm that storage containers are created with the supplied name). However, it’s not working in non-production slots either.For reference for anyone who wants to customize configuration, Azure Functions now has a proper way to handle this: https://docs.microsoft.com/en-us/azure/azure-functions/functions-dotnet-dependency-injection#customizing-configuration-sources.
@ConnorMcMahon think I’m still seeing this on
2.1.1
and2.2.0
.I have a
host.json
with the following contents:I use the attribute
[DurableClient(TaskHub = "%CustomHubName%")]IDurableClient client
. I then set theCustomHubName
appsetting differently per slot and it does not match the app name but still receive the error.In fact even when not using slots, the appsetting or
host.json
value is never used and it always uses the default task hub name.I’ve tried using setting
AzureFunctionsJobHost__extensions__durableTask__hubName
with and without a value in thehost.json
too but still it uses the default.I’ve also tried putting a hardcoded value in the
host.json
instead of an appsetting and again it still uses the default.Note: it works as expected locally, but when deployed to an Azure Function (v3) it doesn’t.
I’m also facing the same issue with different versions from 2.0.0 to 2.2.1 and azure function V3 and .Net Core 3.1 But when I’ve changed my function to V2 it fixed the issue for me.
I think the issue should be reopened, but I hope my workaround can help someone for who is not critical to use V3
function app name : rclfunctions - staging (staging slot)
App Insights is not set up for the function app. Do I need to set it up for you to diagnose?
Just to be clear, I am specifying the TaskHub in my
host.json
but I am getting the same error message as the author so I was wondering if I also need it as an app setting and configured in the trigger.Right now I am just throwing darts at the wall trying to get my slots working.