Azure App Configuration is an Azure service that is used for storing sensitive settings. We like it because every member on your team can reference the same app settings. No more copy/pasting app settings trying to stay up to date with changes that someone else made. Although, spoiler alert, it is still possible to use an appSettings.json file if you really want to (more details below)
- Download this template, which includes all of the settings used in Headstart. More detail on what each setting means is available here
- Navigate to your Azure App Configuration on Azure
- Search for Import/export (left navbar)
- Under "Source Service" click "Configuration File"
- Under language click "Other"
- Search for your json file
- Click "Apply"
- Now if you navigate to your Configuration explorer you should see all of the imported settings
- Navigate to your Azure App Configuration on Azure
- Search for "Access Keys" (left navbar)
- Click on "Read-only keys"
- We're not performing any write operations so its more secure to just use the readonly keys
- Copy the primary key "Connection String"
- Read the following section for information on how to configure the connection string in Headstart
In order for you application to consume the settings, you'll need to define the environment variable APP_CONFIG_CONNECTION
whose value should be the connection string (read-only) to your azure app configuration. Please see "Retrieving the connection string" if needed
- Open the Headstart Solution in Visual Studio
- Right click the Headstart.API project
- Go to "Properties"
- Under Debug/General click on "Open debug launch profiles UI"
- Create a new launch profile of type "Project"
- Scroll down to "Environment Variables" and define the variable with the name
APP_CONFIG_CONNECTION
and the value with your azure app configuration connection string
After doing this you will be able to select your launch profile from the dropdown to start your project
Note: It is also possible to consume app settings from a JSON file while developing locally. Simply add an
appSettings.json
file to the root of the Headstart.API project. Settings defined here are applied after and override any settings in the azure app configuration.
- Navigate to your middleware app service on Azure
- Search for "Configuration" (left navbar)
- Click on "New application setting"
- Define the variable with the name
APP_CONFIG_CONNECTION
and the value with your azure app configuration connection string