cloud config_error ai_generated true

Microsoft.Azure.WebJobs.Extensions.Storage:'AzureWebJobsStorage' 的值缺失或为空。请设置此应用程序设置。

Microsoft.Azure.WebJobs.Extensions.Storage: The value for 'AzureWebJobsStorage' is missing or empty. Please set this app setting.

ID: cloud/azure-function-storage-account-missing

其他格式: JSON · Markdown 中文 · English
95%修复率
90%置信度
1证据数
2024-01-20首次发现

版本兼容性

版本状态引入弃用备注
Azure Functions Runtime 4.x active
Azure Functions Core Tools 4.0.5907 active

根因分析

Azure Functions 需要在 AzureWebJobsStorage 应用设置中提供存储帐户连接字符串,用于触发器和状态管理等内部操作。

English

Azure Functions require a storage account connection string in the AzureWebJobsStorage app setting for internal operations like triggers and state management.

generic

官方文档

https://learn.microsoft.com/en-us/azure/azure-functions/functions-app-settings#azurewebjobsstorage

解决方案

  1. 在 Azure 门户或通过 CLI 设置 AzureWebJobsStorage 应用设置:az functionapp config appsettings set --name <function-app> --resource-group <rg> --settings AzureWebJobsStorage="DefaultEndpointsProtocol=https;AccountName=<storage-account>;AccountKey=<key>;EndpointSuffix=core.windows.net"
  2. 本地开发时,将连接字符串添加到 local.settings.json:{ "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "UseDevelopmentStorage=true" } } 并确保 Azure 存储模拟器或 Azurite 正在运行。
  3. 使用托管标识代替连接字符串:设置 AzureWebJobsStorage__accountName=<storage-account> 并为函数应用的托管标识分配 'Storage Blob Data Contributor' 和 'Storage Queue Data Contributor' 角色。

无效尝试

常见但无效的做法:

  1. 90% 失败

    Setting AzureWebJobsStorage to a non-existent storage account name causes a different error later.

  2. 85% 失败

    Using a SAS token without proper permissions (e.g., missing Table/Queue service) leads to '403 Forbidden' on runtime start.

  3. 100% 失败

    Disabling the Storage extension in host.json is not supported and breaks triggers.