When building an Azure Functions project containing a function that is queue-triggered, the build SDK emits a warning that an app setting with a corresponding name to the value of the trigger's Connection property could not be found. However, it appears that Azure Functions supports connection string names in addition to setting names for the property's value and the function runs just fine.
```c#
[FunctionName("foo")]
public static async Task Run(
[QueueTrigger("%QueueName%", Connection = "bar")] string item,
TraceWriter log)
{
...
}
## Expected result
No warning is emitted if there is either a `bar` setting or a `bar` connection string.
## Actual result
Warning: Function [foo]: cannot find value named 'bar' in local.settings.json that matches 'connection' property set on 'queueTrigger'.
This is despite a `bar` connection string in `local.settings.json`:
```json
...
"ConnectionStrings": {
"bar": "..."
}
...
The above example function runs just fine locally; the warning is simply extraneous.
The warning appears to come from this line, which is not checking connection strings.
Really thats poor, its misleading.
Is this still happening?
Yes, it is still happening on version 2.18.3 as of today.
Still happening for me as of 19 Mar 2020!
This is how the method should look like
[FunctionName("yourfunctionname")]
public async Task Run(
[QueueTrigger("yourqueuename", Connection = "StorageConnectionString")] string message,
CancellationToken cts)
{
...
}
This is how you local.settings.json should look like:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true"
"StorageConnectionString": "DefaultEndpointsProtocol=https;AccountName=youraccountname;AccountKey=youraccountkey;EndpointSuffix=core.windows.net"
}
}
Still happening with local.settings.json that has connection strings defined like
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true"
},
"ConnectionStrings": {
"SomeConnectionString": ""
}
}
The function triggers look for a value in ConnectionStrings so this should be a valid option that doesn't generate a build warning.
Still happening 3 1/2 years later...
+1 facing this issue literally today.
Poor, that it is still not fixed in:
Azure Functions Core Tools
Core Tools Version: 3.0.3442
Function Runtime Version: 3.0.15417.0
Probably it only needs one or two lines to be changed, for not getting that error
Warning: Cannot find value named 'CoreServiceBus' in local.settings.json that matches 'connection' property set on 'serviceBusTrigger' in '.....\bin\Debug\netcoreapp3.1\ServiceBusQueueTriggerCSharp\function.json'. You can run 'func azure functionapp fetch-app-settings <functionAppName>' or specify a connection string in local.settings.json.
My function trigger:
```C#
[FunctionName("ServiceBusQueueTriggerCSharp")]
public async Task RunAsync([ServiceBusTrigger("core-files-thumbnails", Connection = "CoreServiceBus")] string message, Int32 deliveryCount, DateTime enqueuedTimeUtc, string messageId, ILogger log)
and local.settings.json:
```json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
},
"ConnectionStrings": {
"CoreServiceBus": "XXXXXXXXXXXXXXXXXXXXXXXXXXXX",
},
}
EITHER remove the error message OR remove reading setting from ConnectionStrings, so that behaviour is consistent.
Most helpful comment
Still happening 3 1/2 years later...