You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure Functions隔离模式启动报错:Settings must be of the form 'name=value'

Azure Functions隔离模式队列触发报错分析

错误信息

Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.AddOrUpdate'. System.Private.CoreLib: Exception has been thrown by the target of an invocation. Azure.Storage.Queues: Settings must be of the form "name=value".

函数代码

[Function(nameof(VesselAddOrUpdate))]
public async Task Run([QueueTrigger("update-or-add-vessel", Connection = "QueueConnection")] QueueMessage vesselJson)
{
    var vessel = System.Text.Json.JsonSerializer.Deserialize<Vessel>(vesselJson.Body);

    Dictionary<string, object> props = new Dictionary<string, object> { { "service", "xx.update.or.add.vessel.job" }, { "vesselName", vessel.VesselName } };

    using (_logger.BeginScope(props))
    {
        var service = new XXServiceAddOrUpdateService(vessel, _repo, _config);
        await ServiceExecutor.RunAsync(service, _logger, false);
    }
}

配置设置

{
    "IsEncrypted": false,
    "Values": {
        "AzureWebJobsStorage": "UseDevelopmentStorage=true",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
        "Q88NotifyCron": "0 0 3 * * WED",
        "Q88Cron": "0 0 7,12,17 * * *",
        "QueueConnection__queueServiceUri": "https://xxx.queue.core.windows.net"
    }
}

相关NuGet包信息

NuGet包信息1
NuGet包信息2


问题原因及解决方案

核心问题

报错根源是队列绑定的连接配置格式不匹配:

  • QueueTrigger默认期望读取标准存储连接字符串(格式为DefaultEndpointsProtocol=https;AccountName=xxx;AccountKey=xxx;...,即"name=value"键值对形式)。
  • 当前配置的QueueConnection__queueServiceUri是Azure SDK v12中用于Azure AD身份验证的配置格式,但QueueTrigger绑定未启用对应支持,导致它将该URI当成普通连接字符串解析,触发格式错误。

解决方案

方案1:使用标准存储连接字符串(快速解决)

将配置中的QueueConnection__queueServiceUri替换为完整的存储账户连接字符串:

"QueueConnection": "DefaultEndpointsProtocol=https;AccountName=你的存储账户名;AccountKey=你的存储账户密钥;EndpointSuffix=core.windows.net"

方案2:启用Azure AD身份验证(生产环境推荐)

若要使用Azure AD托管标识访问存储队列,需完成以下配置:

  1. Azure端权限配置:
    • 为函数应用启用系统托管标识。
    • 给该托管标识分配Storage Queue Data Contributor角色到目标存储账户。
  2. 本地/云端配置修正:
    在配置中添加身份验证标识,让绑定识别Azure AD模式:
    "QueueConnection__queueServiceUri": "https://xxx.queue.core.windows.net",
    "QueueConnection__credential": "managedidentity"
    
  3. 本地运行注意事项:
    本地开发时需确保已通过Azure CLI/Visual Studio等工具登录Azure,且当前账户拥有访问存储队列的权限。

额外检查

确认Microsoft.Azure.Functions.Worker与Microsoft.Azure.Functions.Worker.Extensions.Storage.Queues的版本兼容,建议使用最新稳定版,避免版本冲突导致的解析异常。


内容的提问来源于stack exchange,提问作者Thomas Segato

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.23 01:10:19