You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am writing an Azure Function (Service Bus Topic Triggered Function in isolated mode) which is part of a bigger solution that has API and other projects. The API reads the configuration settings from Azure App Configuration Service and that is working fine.
What I want to do is read the settings in my Function from there and set the bindings for the Function based on those settings however it is not working.
Here's what I did:
I created an App Configuration Service in my Azure Subscription and added the configuration keys there.
Then I added the reference to this App Configuration Service in Program.cs using the code like below:
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
var host = new HostBuilder()
.ConfigureAppConfiguration(builder =>
{
builder.AddAzureAppConfiguration(
"Endpoint=https://myfunctionconfig.azconfig.io;Id=somerandomstring;Secret=otherrandomstring",
optional: false)
.AddEnvironmentVariables()
.Build();
})
.ConfigureFunctionsWorkerDefaults()
.Build();
host.Run();
My Function code looks something like this:
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Logging;
namespace ServiceBusTriggeredFunction;
public static class ServiceBusTopicTrigger
{
[Function("ServiceBusTopicTrigger")]
public static void Run([ServiceBusTrigger("%FunctionsConfiguration:ServiceBusTopicTrigger:Topic%", "%FunctionsConfiguration:ServiceBusTopicTrigger:Subscription%", Connection = "FunctionsConfiguration:ServiceBusTopicTrigger:Connection")] string mySbMsg,
FunctionContext context)
{
var logger = context.GetLogger("ServiceBusTopicTrigger");
logger.LogInformation($"C# ServiceBus topic trigger function processed message: {mySbMsg}");
}
}
However when I run the code locally, I am getting the following error:
The 'ServiceBusTopicTrigger' function is in error:
Microsoft.Azure.WebJobs.Host: Error indexing method
'Functions.ServiceBusTopicTrigger'. Microsoft.Azure.WebJobs.Host:
'%FunctionsConfiguration:ServiceBusTopicTrigger:Topic%' does not
resolve to a value.
Basically the issue is that it is not able to read the settings value (FunctionsConfiguration:ServiceBusTopicTrigger:Topic).
However the same code works flawlessly if I define the same settings in local.settings.json.
I am wondering if someone can tell me what I am doing wrong here and if there's a way for me to read the settings from an App Configuration Service (I guess the same would apply to appsettings.json as well) and set the Function bindings based on the settings.
The text was updated successfully, but these errors were encountered:
@gmantri worker configuration sources are not currently supported by extensions/bindings, as that configuration must be available at the app/platform level (platform components depend on that configuration).
Cross posting from Stack Overflow: https://stackoverflow.com/questions/75815924/how-to-use-azure-app-configuration-service-with-azure-functions-in-local-dev-env.
I also found a similar issue on Microsoft Q&A: Azure Function - CosmosDbTrigger - Bind variables from Keyvault and App configuration instead of appsettings but the solution provided there is not working.
I am writing an Azure Function (Service Bus Topic Triggered Function in isolated mode) which is part of a bigger solution that has API and other projects. The API reads the configuration settings from Azure App Configuration Service and that is working fine.
What I want to do is read the settings in my Function from there and set the bindings for the Function based on those settings however it is not working.
Here's what I did:
Program.cs
using the code like below:However when I run the code locally, I am getting the following error:
Basically the issue is that it is not able to read the settings value (
FunctionsConfiguration:ServiceBusTopicTrigger:Topic
).However the same code works flawlessly if I define the same settings in
local.settings.json
.I am wondering if someone can tell me what I am doing wrong here and if there's a way for me to read the settings from an App Configuration Service (I guess the same would apply to
appsettings.json
as well) and set the Function bindings based on the settings.The text was updated successfully, but these errors were encountered: