Azure / azure-functions-vs-build-sdk

MSBuild task for Azure Functions
MIT License
98 stars 65 forks source link

Suppress Warning "cannot find value named '{0}' in local.settings.json #519

Open qualitas-software opened 3 years ago

qualitas-software commented 3 years ago

I exclude local.settings.json from checkin as developers can configure some aspects separately as needed.

I have a storage connection string for a queue trigger which I default (ie- set as a convention) in Startup. When deployed, this will be filled from a keyvault, but in dev the default is UseDevelopmentStorage=true.

This all works, but I get an unwanted warning telling me I must set the value in local.settings.json, as follows:

Function [MyListener]: cannot find the value named 'MyStorage:ConnectionString' in local.settings.json that matches 'connection' property set of 'QueueTrigger'

I would like to add a code suppression for this warning. Is this possible ?

fowl2 commented 2 years ago

This warning appears to be generated here: https://github.com/Azure/azure-functions-vs-build-sdk/blob/32ebc25b282fe08ebb283178150450755f2d1044/src/Microsoft.NET.Sdk.Functions.Generator/FunctionJsonConverter.cs#L261

It also appears erroneously when using the "" syntax, eg. with service bus with managed identity "`connectionNamefullyQualifiedNamespace`".


As a workaround, it seems that replacing local.settings.json with properties\launchSettings.json works, eg:

{
  "profiles": {
    "project.name": {
      "commandName": "Project",
      "commandLineArgs": "--csharp",
      "environmentVariables": {
        "AzureWebJobsStorage": "UseDevelopmentStorage=true",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet",
        "connectionName__fullyQualifiedNamespace": "servce-bus-namespace-goes-here"
      }
    }
  }
}
petrkoutnycz commented 1 year ago

I'm having this issue as well, not even adding an env variable to `launchSettings' helps. Any news regarding this bug?

jameswoodley commented 1 year ago

Same issue here when using the __fullyQualifiedNamespace pattern.

This is at build time, so environment variables don't make a difference

DanielRNichols commented 1 year ago

Same issue here when using managed identities with the service bus. I had seen a previous issue raised by @petrkoutnycz https://github.com/Azure/azure-sdk-for-net/issues/32840 in which it was marked as resolved, and to update to the latest version of azure core tools; however, that does not seem to be working in my case.

petrkoutnycz commented 1 year ago

@DanielRNichols I believe it works with the latest version of SDK, at least for me :-)

michasacuer commented 9 months ago

@petrkoutnycz Which SDK did you update? I go back to my function after couple of months and it stopped working (i didn't do anything in the codebase)