In the example I found, you need to setx AZURE_STORAGE_CONNECTION_STRING for a real environment variable. But Azure function does not have that, only configuration.
I set it in the local.settings.json file but when I run it has an issue with it and the function does not load.
How do I get the connection string to work?
[2023-09-12T11:14:30.192Z] Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.ContractQueue'. System.Private.CoreLib: Exception has been thrown by the target of an invocation. Azure.Storage.Queues: No valid combination of account information found.
[2023-09-12T11:14:30.214Z] Error indexing method 'Functions.ContractQueue'
[2023-09-12T11:14:30.218Z] Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.ContractQueue'. System.Private.CoreLib: Exception has been thrown by the target of an invocation. Azure.Storage.Queues: No valid combination of account information found.
[2023-09-12T11:14:30.222Z] Function 'Functions.ContractQueue' failed indexing and will be disabled.
[2023-09-12T11:14:30.294Z] The 'ContractQueue' function is in error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.ContractQueue'. System.Private.CoreLib: Exception has been thrown by the target of an invocation. Azure.Storage.Queues: No valid combination of account information found.
2
Answers
"AzureWebJobsAzureWebJobsStorage": "UseDevelopmentStorage=true", must be in the in the settings
Addition to my comment, while creating the azure queue triggered function you will get below options in the function template due to the below item
If configuration dependencies is ticked, then you will prompted to the following options in next step
For first two options, you will need to give the connection string as below in your local settings file and in function.cs file and this will use local storage queue emulator.
local.settings
function.cs
But if you will choose Azure Storage option, then it will show you all the storage account in your subscription. Select one of the storage account and provide the connection string name as below
Function.cs file will look like below
No need to add
AZURE_STORAGE_CONNECTION_STRING
in your local settings file because its already stored in secrets.json file.Output:
Please Note: You need to use latest package of
Microsoft.Azure.Functions.Worker.Extensions.Storage.Queues
andAzure.Storage.Queues