Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress the connection warning message when using Managed Identity #524

Open
shibayan opened this issue Sep 1, 2021 · 3 comments
Open

Comments

@shibayan
Copy link

shibayan commented Sep 1, 2021

When using Managed Identity in Binding / Trigger, you need to specify a nested value prefixed with the connection name. (Example: <CONNECTION_NAME_PREFIX>__serviceUri)

https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference#connection-properties

Function Build SDK does not take nested values into account, so even if you add the correct settings to local.settings.json, it will warn you that the connection cannot be found, which is an unnecessary warning.

Build warning

C:\Users\shibayan\.nuget\packages\microsoft.net.sdk.functions\3.0.13\build\Microsoft.NET.Sdk.Functions.Build.targets(32,5): 
warning : Function [Function2]: cannot find value named 'CosmosConnection' in local.settings.json that matches 'connection' property set on 'cosmosDBTrigger'

Repro code

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "CosmosConnection__accountEndpoint": "https://***.documents.azure.com:443/"
  }
}
public class Function2
{
    [FunctionName("Function2")]
    public void Run([CosmosDBTrigger(
                        databaseName: "SampleDB",
                        containerName: "TodoItem",
                        Connection = "CosmosConnection",
                        LeaseContainerName = "leases")]
                    IReadOnlyList<TodoItem> items, ILogger log)
    {
        if (items != null && items.Count > 0)
        {
            log.LogInformation("Documents modified " + items.Count);
            log.LogInformation($"First document Id = {items[0].Id}, Title = {items[0].Title}");
        }
    }
}
@mattchenderson
Copy link
Contributor

This looks like it comes from:

_logger.LogWarning($"Function [{functionName}]: cannot find value named '{appSettingName}' in {settingsFileName} that matches '{token.Key}' property set on '{binding["type"]?.ToString()}'");

Related changes had to be made to the Core Tools, although those could force the process to exit, while this seems to just be warning level. This should still be fixed. Core Tools PRs for reference in case it's useful in resolution:

@huytranbandlab
Copy link

Hello, this issue still happens on version 4.1.3

@akimotochan
Copy link

akimotochan commented Mar 12, 2024

@mattchenderson still happening at 4.3.0 :(

Any guidance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants