使用 Azure 应用程序配置中设置的 Azure Durable Function TaskHub 名称

Use Azure Durable Function TaskHub name set from Azure App Configuration

是否可以根据存储在 Azure 应用配置服务中的值设置 Azure Durable Function 的 TaskHub 名称?我的 host.json 文件是:

{
    "version": "2.0",
    "extensions": {
        "durableTask": {
            "hubName": "%TaskHubName%"
        }
    }
}

我正在尝试在我的 Orchestration 客户端中使用 binder

[FunctionName("Test_HttpStart")]
public static async Task<HttpResponseMessage> HttpStart(
    [HttpTrigger(AuthorizationLevel.Function, "get")] HttpRequestMessage req,
    IBinder binder)
{
    var starter = await binder.BindAsync<IDurableOrchestrationClient>(
        new DurableClientAttribute { TaskHub = Configuration["TaskHubName"] });

当我在 local.settings.json:

中定义了 TaskHubName 时,这有效
{
    "IsEncrypted": false,
    "Values": {
        "AzureWebJobsStorage": "UseDevelopmentStorage=true",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet",
        "TaskHubName": "TestTaskHubName"
}

但是当我从 local.settings.json 中删除它并从 Azure 应用程序配置中检索该值时:

Configuration = new ConfigurationBuilder()
    .AddAzureAppConfiguration(options =>
    {
        _ = options.Connect(Environment.GetEnvironmentVariable("app-configuration-connection-string"))
            .Select(@"TaskHubName");
    })
    .AddEnvironmentVariables()
    .Build();

我收到错误:

Microsoft.Azure.WebJobs.Extensions.DurableTask: Task hub name '%TaskHubName%' should contain only alphanumeric characters, start with a letter, and have length between 3 and 45. Microsoft.WindowsAzure.Storage: Invalid container name. Check MSDN for more information about valid container naming.

因此,即使我可以看到 Azure 应用程序配置中的值被拉下并存在于应用程序的配置中,但它看起来并没有被使用。是否可以使用 Azure 应用程序配置中的值作为 Durable Function 的 TaskHub 名称?

运行时绑定应该有效,但错误可能来自启动序列,它从 host.json 中获取值,用于 internal queue triggers.[=13 等其他功能=]

不幸的是,AFAIK 现在没有办法解决这个问题。

不过,您可以对应该支持这种情况的 feature request to support app configuration references 投赞成票。