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

Azure Function Isolated Mode. Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions....'. Microsoft.Azure.WebJobs.Host: '%Azure:ServiceBus:Queue%' does not resolve to a value. #3070

Open
textbytext opened this issue Apr 4, 2024 · 1 comment

Comments

@textbytext
Copy link

textbytext commented Apr 4, 2024

Azure Function Isolated Mode.

Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions....'. Microsoft.Azure.WebJobs.Host: '%KEY:NAME%' does not resolve to a value.

My configuration:

<PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
</PropertyGroup>
...
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.21.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.2" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.2.0" />        
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.EventGrid" Version="3.4.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.17.0" />

Usage:

[Function("Function-Name")]
public async Task Run(
    [ServiceBusTrigger(
        queueName: "%Azure:ServiceBus:Queue%",
        Connection = "SERVICEBUS:CONNECTION:STRING")]
    ServiceBusReceivedMessage message,
    ServiceBusMessageActions messageActions,
    CancellationToken cancellationToken)
{
   ...
}

"%Azure:ServiceBus:Queue%" and "SERVICEBUS:CONNECTION:STRING" are taking from an AzureKeyVault (HostBuilder config)

var host = new HostBuilder()
    .ConfigureFunctionsWorkerDefaults()
    .ConfigureHostConfiguration(builder =>
    {
        builder.AddAzureKeyVaultSettingsConfiguration(GetKeyVaultName());
    })
    .ConfigureServices(services =>
    {
        ...
    })
    .Build();

Error:
Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.Function-Name'. Microsoft.Azure.WebJobs.Host: '%Azure:ServiceBus:Queue%' does not resolve to a value.

My assumption:
The problem is in the FunctionIndexProvider.cs file.

FunctionIndexer indexer = new FunctionIndexer(_triggerBindingProvider, 
...
_instanceServicesFactory, 
null, 
_sharedQueue, 
...
_defaultRetryStrategy); 

The INameResolver does not passing (null instead) to the constructor.

@textbytext textbytext changed the title Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions....'. Microsoft.Azure.WebJobs.Host: '%KEY:NAME%' does not resolve to a value. Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions....'. Microsoft.Azure.WebJobs.Host: '%Azure:ServiceBus:Queue%' does not resolve to a value. Apr 4, 2024
@textbytext textbytext changed the title Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions....'. Microsoft.Azure.WebJobs.Host: '%Azure:ServiceBus:Queue%' does not resolve to a value. Azure Function Isolated Mode. Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions....'. Microsoft.Azure.WebJobs.Host: '%Azure:ServiceBus:Queue%' does not resolve to a value. Apr 4, 2024
textbytext pushed a commit to textbytext/azure-webjobs-sdk that referenced this issue Apr 4, 2024
The nameResolver parametr added
@eriktack
Copy link

I can only get my function app to read %somevalue% in a queue trigger if it is set as an environment variable after switching to isolated mode. If it is set in appsettings.json its ignored and I get the same error as you get.

It seems like whatever INameResolver is used in Microsoft.Azure.WebJobs.Host.NameResolverExtensions.ResolveWholeStringCore when configuring %%-values is only able to read environment variables.

Note: In the application, if i inject IConfiguration anywhere, it has all values from appsettings.json.

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

No branches or pull requests

2 participants