cloud config_error ai_generated true

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

Also available as: JSON · Markdown · 中文
95%Fix Rate
90%Confidence
1Evidence
2024-01-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Azure Functions Runtime 4.x active
Azure Functions Core Tools 4.0.5907 active

Root Cause

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

generic

中文

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

Official Documentation

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

Workarounds

  1. 95% success Set the AzureWebJobsStorage app setting in the Azure Portal or via CLI: az functionapp config appsettings set --name <function-app> --resource-group <rg> --settings AzureWebJobsStorage="DefaultEndpointsProtocol=https;AccountName=<storage-account>;AccountKey=<key>;EndpointSuffix=core.windows.net"
    Set the AzureWebJobsStorage app setting in the Azure Portal or via CLI: 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. 90% success For local development, add the connection string to local.settings.json: { "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "UseDevelopmentStorage=true" } } and ensure Azure Storage Emulator or Azurite is running.
    For local development, add the connection string to local.settings.json: { "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "UseDevelopmentStorage=true" } } and ensure Azure Storage Emulator or Azurite is running.
  3. 85% success Use managed identity instead of connection string: set AzureWebJobsStorage__accountName=<storage-account> and assign the 'Storage Blob Data Contributor' and 'Storage Queue Data Contributor' roles to the function app's managed identity.
    Use managed identity instead of connection string: set AzureWebJobsStorage__accountName=<storage-account> and assign the 'Storage Blob Data Contributor' and 'Storage Queue Data Contributor' roles to the function app's managed identity.

中文步骤

  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' 角色。

Dead Ends

Common approaches that don't work:

  1. 90% fail

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

  2. 85% fail

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

  3. 100% fail

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