Azure Durable Function构建报错:无法解析Storage连接及Provider为空
解决Azure Durable Function启动时的"Unable to resolve the Azure Storage connection named 'Storage'"错误
报错信息
A host error has occurred during startup operation 'xxxxxxxx'. Microsoft.Azure.WebJobs.Extensions.DurableTask: Unable to resolve the Azure Storage connection named 'Storage'. Value cannot be null. (Parameter 'provider') Failed to run function CLI command from staging folder(azure-functionsxxxxxxxxxxxx), value cannot be null. (Parameter 'provider').
问题原因
Durable Task扩展默认会尝试查找名为Storage的Azure存储连接字符串配置项,但你的local.settings.json中仅配置了AzureWebJobsStorage,导致扩展无法找到所需的连接配置,从而启动失败。
解决方案
方案1:指定Durable扩展使用已有的AzureWebJobsStorage配置
修改local.settings.json,在Values节点中添加Durable Task的连接配置,指向已有的存储连接:
{ "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "<你的实际存储账户连接字符串>", "FUNCTIONS_WORKER_RUNTIME": "java", "DurableTask:StorageProvider:ConnectionStringName": "AzureWebJobsStorage" } }
方案2:添加名为Storage的连接配置项
直接在Values中添加Storage项(不推荐,会产生冗余配置,但可快速验证问题):
{ "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "<你的实际存储账户连接字符串>", "FUNCTIONS_WORKER_RUNTIME": "java", "Storage": "<你的实际存储账户连接字符串>" } }
额外检查项
- 确保
<你的实际存储账户连接字符串>已替换为Azure存储账户的真实连接字符串,而非占位符 - 确认
local.settings.json位于项目根目录,本地运行时Function Host能正确读取该文件 - 当前使用的
durabletask-azure-functions:1.1.0与azurefunctions插件1.12.0版本兼容,无需调整依赖版本
内容的提问来源于stack exchange,提问作者SomeGuy
相关产品推荐
相关产品推荐

