Reputation: 4759
I am trying to implement Azure Blob trigger for our ADLS2 container directory. I am following these two MS docs for that
Azure Blob storage trigger for azure functions
Azure function extension libraries
So here is our local.settings.json
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"myconnection__blobServiceUri": "https://myadls2account.blob.core.windows.net",
"myconnection__queueServiceUri": "https://myadls2account.blob.core.windows.net"
}
}
And here is our blob trigger
[FunctionName("Function1")]
public void Run([BlobTrigger("sample/my-directory/{name}",Connection = "myconnection")]Stream myBlob, string name, ILogger log)
{
log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
}
But when executing it triggers the below error
Error indexing method 'Function1'
Microsoft.Azure.WebJobs.Host: Error indexing method 'Function1'. Microsoft.Azure.WebJobs.Extensions.Storage: Storage account connection string 'AzureWebJobsmyconnection' does not exist. Make sure that it is a defined App Setting.
Please share your thoughts what did I missed or what I did wrong?
Upvotes: 2
Views: 3396
Reputation: 376
You have a naming issue in your blobtrigger:
[FunctionName("Function1")]
public void Run([BlobTrigger("sample/my-directory/{name}",Connection = "myconnection")]Stream myBlob, string name, ILogger log)
{
log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
}
As per your code, you defined connection as "myconnection". So the runtime is looking for a key "myconnection" in your local.settings.json. If this key is not available, it will look for "AzureWebJobsmyconnection".
So there are several solutions now:
Of course it is possible to define several different variables in the local.settings.json for different blob triggers. So something like this:
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"MyFirstBlob": "{first}",
"MySecondBlob": "{second}"
and then use those in your blob trigger connections
Connection = "MyFirstBlob" or connection = "MySecondBlob"
Upvotes: 2