question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WebJobsHostBuilderExtensions.ConfigureWebJobs should not add configuration sources

See original GitHub issue

When configuring the HostBuilder the order of ConfigureWebJobs and ConfigureAppConfiguration is significant, as ConfigureWebJobs adds “appsettings.json” and environment variables as configuration sources. This can lead to invalid configuration values and unexpected behavior, as the order of configuration sources defined in ConfigureAppConfiguration is not the definitive list of configuration sources.

Repro steps

  1. Create a new HostBuilder, call ConfigureAppConfiguration with one or more configuration sources that has values that should take precedence over appsettings.json and/or environment variables

  2. Call ConfigureWebJobs on the host builder

  3. Access a configuration value (example: in hostBuilder.ConfigureServices((context, services) => { var configValue = context.Configuration["ExampleValue"]; })

  4. Build and run the Host.

Expected behavior

ConfigureWebJobs should not manipulate configuration sources at all, or at the very least have an option to disable the behavior. Configuration values should appear as defined in ConfigureAppConfiguration.

Actual behavior

The rogue configuration sources are added to the configuration sources and may provide invalid configuration values.

Known workarounds

Call ConfigureWebJobs before ConfigureAppConfiguration. The rogue application sources are still added, but the desired sources takes precedence.

Related information

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:24
  • Comments:47 (10 by maintainers)

github_iconTop GitHub Comments

14reactions
fhurtacommented, May 3, 2019

I just spent a day tracking down why my configuration does not work. I was adding Key Vault configuration and environment specific settings which seemed to be quite easy task but after deployment to Azure it didn’t work. I really didn’t expect that configuring webjobs add appsettings.json on top of my configuration effectively reverting all the specific changes

This is quite old issue, still not fixed, causing unnecessary waste of time and workarounds… 👎

12reactions
thomaslevesquecommented, Feb 13, 2019

What’s the official stance on this? This behavior is clearly incorrect, as it silently overrides the user defined configuration

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upgrading to WebJobs SDK 3.0 has broken overridden ...
Just figured it out. The extension method for ConfigureWebJobs() calls ConfigureAppConfiguration() and automatically adds appsettings.
Read more >
How to use the WebJobs SDK - Azure App Service
You can configure the behavior of some triggers and bindings. The process for configuring them depends on the SDK version. Version 3.x: Set ......
Read more >
Converting Azure WebJobs to .NET Core
ConfigureWebJobs () ). Source for this is available here. Only thing we need to configure is to add command-line argument support.
Read more >
[Configuration in Azure Functions Series - Part 3] Add ASP ...
This is part three of a series exploring .NET Core configuration, with an emphasis on Azure Functions. In this article, we look at...
Read more >
Untitled
Azure function webjobsbuilderextensions.cs not found WebThe host/runtime that powers Azure Functions. 1.8K: HTBox/allReady This repo contains the code for ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found