Hi ,
I'm using .Net 4.8 Version, all my connection string & secret Keys are stored in App.config. I want to make use of Azure App configuration in order to read the values from Azure rather than hardcode.
Thanks,
Hi ,
I'm using .Net 4.8 Version, all my connection string & secret Keys are stored in App.config. I want to make use of Azure App configuration in order to read the values from Azure rather than hardcode.
Thanks,
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Deepak RawatPosted Jul 5, 2023, 11:30 AM
Mohamed Azarudeen ZPosted Jul 5, 2023, 11:00 AM
Hi Shiva
To use Azure App Configuration to read values such as connection strings and secret keys instead of hardcoding them in your .NET 4.8 application's App.config, you can follow these steps:
Create an Azure App Configuration: First, you need to create an Azure App Configuration service in your Azure portal. This service will store the configuration settings you want to retrieve in your .NET application.
Install Azure.Extensions.AspNetCore.Configuration.AzureAppConfiguration Package: In your .NET 4.8 project, install the
Azure.Extensions.AspNetCore.Configuration.AzureAppConfigurationNuGet package. This package provides the necessary extension to read settings from Azure App Configuration.Update Program.cs: In the
Program.csfile of your .NET application, add the following code to set up the Azure App Configuration provider:Replace Connection Strings in App.config: Remove the connection strings and other sensitive information from your
App.configfile since you'll be reading them from Azure App Configuration.Set Up Access to Azure App Configuration: In the
options.Connect()method call, replacewith the actual connection string of your Azure App Configuration service. This will allow your application to access the configurations stored there.Secure Access to Azure App Configuration: Ensure that your application has the necessary permissions to access the Azure App Configuration service securely. You can use Managed Identity or a Service Principal for this purpose, depending on your security requirements.
Hope this helps