0

I created an isolated process Azure functions for queue trigger. Based on link I created managed identify string using <CONNECTION_NAME_PREFIX>__queueServiceUri. This property works locally when I specify in local.settings.json. But it doesn't work when I specify in appsettings.json. Below is my program.cs code

var configuration = new ConfigurationBuilder().AddEnvironmentVariables()
    .AddCommandLine(args)
    .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
    .Build();

var host = new HostBuilder().ConfigureHostConfiguration(config => {
config.AddConfiguration(configuration);
}).ConfigureFunctionsWorkerDefaults().Build();

Function code:

 [Function("BlobQueueTrigger")]
    public async Task RunAsync([QueueTrigger("datablobqueue", Connection = "blobQueue")] string blobQueueItem)
    {}

Property in appsettings:

"blobQueue__queueServiceUri": "https://mydatastorage.queue.core.windows.net"
DxG
  • 147
  • 4
  • 17

1 Answers1

3

According to the documentation you referenced above, blobQueue__queueServiceUri must be defined as an Environment Variable, not in appsettings.json. This means you need to set it as an Application Setting in the portal. When working locally, values set in local.settings.json are indeed loaded as Environment Variables

Been a while since I dug into this, but I think it needs to access that value before it actually starts your process. Hence the custom configuration providers you have defined in Program.cs aren't yet loaded.

Thomas
  • 24,234
  • 6
  • 81
  • 125
Harris Spivack
  • 275
  • 1
  • 6
  • yes. App setting in portal is working. I would prefer the property within the code than in portal. If it is not possible within code , then portal is the only option. – DxG Oct 19 '22 at 20:58