This post on using App Configuration using .NET Full Framework was based on a contribution by Steven Hack.
My last post Azure App Configuration: an introduction received a lot of good feedback. And one of those pieces of feedback was a question if it’s also possible to use App Configuration if you’re using Full Framework.
The short answer: yes, this is possible!
For the slightly longer answer: keep reading 🤓
There are a couple of things you need to keep into account if you want to use App Configuration in .NET FF. This is a list of things that had to be in place to be able to get App Configuration working with FF:
To be able to use App Configuration in .NET FF, you need to add it as a configuration builder. You can do so in the
type="System.Configuration.ConfigurationBuildersSection, System.Configuration, Version=22.214.171.124, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
<!-- Use the endpoint if you want to use Managed Identities.
The connection string parameter is the old conventional way.
The latest version of the NuGet package does not support connection string anymore.
type="Microsoft.Configuration.ConfigurationBuilders.AzureAppConfigurationBuilder, Microsoft.Configuration.ConfigurationBuilders.AzureAppConfiguration, Version=126.96.36.199, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add key="Setting1" value="local" />
Using it 🧰
With all the plumbing out of the way, we can start using App Configuration. Look closely, since this next section contains all the code you need to get it up & running. Be sure not to miss anything!
This example reads the setting with name Setting1:
var setting = ConfigurationManager.AppSettings["Setting1"];
As a result, if the setting with name ‘Setting1’ is in App Configuration, it will take that one. If it’s not there but is in the Application Settings of the Azure App Service, that’s the value that will be used. And if that is not available, but there is a setting with that name in the
appsettings.json file, that will be the provided value.
You should be good to go!
Thanks again to Steven Hack for providing the example. His solution was based on the article Create a .NET Framework app with Azure App Configuration.
If you have any questions, don’t hesitate to contact me. Hope this helps!