Azure / azure-functions-vs-build-sdk

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

Build output warnings don't accomodate identity-based connections #541

Open mattchenderson opened 2 years ago

mattchenderson commented 2 years ago

The Build process complains with warnings if you use identity-based connections for testing locally.

For example, my BlobTrigger attribute might be [BlobTrigger("samples-workitems/{name}", Connection = "myblobaccount")], and in my local.settings.json, I have myblobaccount__serviceUri set to a valid service URI. This is perfectly valid, but the build output shows a warning:

cannot find value named 'myblobaccount' in local.settings.json that matches 'connection' property set on 'blobTrigger'

The same is also true if you do the same style of thing for AzureWebJobsStorage:

Missing value for AzureWebJobsStorage in local.settings.json. This is required for all triggers other than httptrigger, kafkatrigger, orchestrationTrigger, activityTrigger, entityTrigger.

The relevant code looks to be here: https://github.com/Azure/azure-functions-vs-build-sdk/blob/main/src/Microsoft.NET.Sdk.Functions.Generator/FunctionJsonConverter.cs

Instead of only looking for an exact match on the key, we should look for it as a prefix. This was already done in the Core Tools which may serve as a reference. Relevant issues: https://github.com/Azure/azure-functions-core-tools/issues/2755 and https://github.com/Azure/azure-functions-core-tools/issues/2552

slaneyrw commented 1 year ago

I'm getting the same error with a ServiceBus trigger. I have the "__fullyQualifiedNamespace" key in the local.settings.json.

Maybe change the detection to "startwith" instead of exact match