Search code examples
azuredockerazure-blob-storageazure-function-appazure-functions-core-tools

Trying to create docker container function app, when i do docker run getting the error "Storage not defined"


Following the microsoft document (https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-function-linux-custom-image?tabs=bash%2Cportal&pivots=programming-language-python) but for Azure Blob Storage trigger template.

When i run docker run -p 8080:80 -it example/azurefunctionsimage:v1.0 getting the below error,

 fail: Host.Startup[402]
fail: Host.Startup[402]
      The 'voice-text' function is in error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.voice-text'. Microsoft.Azure.WebJobs.Extensions.Storage: Storage account connection string 'AzureWebJobsStorage' does not exist. Make sure that it is a defined App Setting.
Hosting environment: Production
Content root path: /
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down.
info: Host.General[316]
      Host lock lease acquired by instance ID '0000000000000000000000000'.
warn: Microsoft.Azure.WebJobs.Script.ChangeAnalysis.ChangeAnalysisService[0]
      Breaking change analysis operation failed
System.InvalidOperationException: The BlobChangeAnalysisStateProvider requires the default storage account 'Storage', which is not defined.
   at Microsoft.Azure.WebJobs.Script.ChangeAnalysis.BlobChangeAnalysisStateProvider.GetCurrentAsync(CancellationToken cancellationToken) in /src/azure-functions-host/src/WebJobs.Script.WebHost/BreakingChangeAnalysis/BlobChangeAnalysisStateProvider.cs:line 40
   at Microsoft.Azure.WebJobs.Script.ChangeAnalysis.ChangeAnalysisService.TryLogBreakingChangeReportAsync(CancellationToken cancellationToken) in /src/azure-functions-host/src/WebJobs.Script.WebHost/BreakingChangeAnalysis/ChangeAnalysisService.cs:line 92

Please help in solving this error..


Solution

  • Azure Functions needs a storage account in order to run locally.

    The best way to add this is to create a Storage Account in Azure and pass the connection string as an environment variable called AzureWebJobsStorage to the docker run command.

    docker run -p 8080:80 -it -e AzureWebJobsStorage="{connection-string}" <docker-id>/mydockerimage:v1.0.0