I have an Azure function in Visual Studio:
[FunctionName("MyQueueProcessor")]
[StorageAccount("StorageConnectionString")]
public static async Task ProcessQueueMessage([QueueTrigger("my-queue")] string message, TextWriter log)
{
logInfo("Start processing message", LogLevel.TRACE, message, log);
}
I have StorageConnectionString set in the Application Settings in the cloud, and when I upload the function from Visual Studio to an Azure App, the function initially runs without issues.
The problem is that the function app restarts frequently, and sometimes when it restarts, the function doesn't run. From looking at Application Insights, I get the following error:
The following 2 functions are in error: ProcessQueueMessage: Microsoft.Azure.WebJobs.Host: Error indexing method 'MyQueueTrigger.ProcessQueueMessage'. Microsoft.Azure.WebJobs.Host: Microsoft Azure WebJobs SDK 'StorageConnectionString' connection string is missing or empty. The Microsoft Azure Storage account connection string can be set in the following ways: 1. Set the connection string named 'StorageConnectionString' in the connectionStrings section of the .config file in the following format , or 2. Set the environment variable named 'StorageConnectionString', or 3. Set corresponding property of JobHostConfiguration. Run: Microsoft.Azure.WebJobs.Host: Error indexing method 'MyTimerTrigger.Run'. Microsoft.Azure.WebJobs.Host: Microsoft Azure WebJobs SDK 'StorageConnectionString' connection string is missing or empty. The Microsoft Azure Storage account connection string can be set in the following ways: 1. Set the connection string named 'StorageConnectionString' in the connectionStrings section of the .config file in the following format , or 2. Set the environment variable named 'StorageConnectionString', or 3. Set corresponding property of JobHostConfiguration.
It appears that sometimes when the function app restarts, the binding to StorageConnectionString fails. How can I prevent this from being an issue?
StorageConnectionString
in thelocal.settings.json
file and publish the function again 2.setAlways On
in theApplication Settings
in the portal – Joy Wang-MSFT"AzureWebJobsStorage": "UseDevelopmentStorage=true"
is for the emulator, you should specify it as your storage connection string. – Joy Wang-MSFT