Set Configuration in Azure using App Service – Portal and CLI
In this article, we shall learn How and where toSet Configuration in Azure using App Service portal for web apps, mobile back end, or API apps using theĀ Azure portal.
We shall also see how to do automation using Azure Portal and Azure CLI.
Today in this article, we will cover below aspects,
To set application configuration and other configs like set environment variables in the Azure portal is simple.
Kindly follow below basic steps.
- Go to the Azure Portal -> Search for “AppServices”
Click on the application for which you want to add or update required configuration details including the environment variable or Urls, keys configuration, etc.
- In the App’s left menu click on Settings -> Configuration – > and Click on Application Settings
- Add/Edit the Application Settings
For ASP.NET and ASP.NET Core, setting app settings in App Service will override the ones in Web.config or appsettings.json.
Configuration update in Bulk – Advanced Edit
Once can use the bulk edit option to add or update configuration in bulk,
[ { "name": "APPINSIGHTS_INSTRUMENTATIONKEY", "value": "64b98bbe-d8ae-470c-9d0f-8875fc294687", "slotSetting": false }, { "name": "APPLICATIONINSIGHTS_CONNECTION_STRING", "value": "InstrumentationKey=64b98bbe-xxxx-xxxx-9d0f;IngestionEndpoint=https://azure.com/", "slotSetting": false }, { "name": "ApplicationInsightsAgent_EXTENSION_VERSION", "value": "~2", "slotSetting": false }, { "name": "ASPNETCORE_ENVIRONMENT", "value": "Production", "slotSetting": false }, { "name": "XDT_MicrosoftApplicationInsights_Mode", "value": "default", "slotSetting": false } ]
Automate configuration setting using Azure CLI
You can use the Azure CLI to create and manage settings from the Azure command-line easily. We shall try Set Environment Variable in Azure using CLI below,
Set Appsettings using Azure CLI
Command
az webapp config appsettings set --name <app-name> --resource-group <resource-group-name> --settings <setting-name>="<value>"
Example
az webapp config appsettings set --name thecodebuzz-ui --resource-group thecodebuzz --settings ASPNETCORE_ENVIRONMENT="Production"
Remove Appsettings using Azure CLI
Command
az webapp config appsettings delete --name <app-name> --resource-group <resource-group-name> --setting-names {<names>}
Example
az webapp config appsettings delete --name thecodebuzz-ui --resource-group thecodebuzz --settings ASPNETCORE_ENVIRONMENT="Production"
References:
Do you have any comments or ideas or any better suggestions to share?
Please sound off your comments below.
Happy Coding !!
Please bookmark this page and share it with your friends. Please Subscribe to the blog to receive notifications on freshly published(2024) best practices and guidelines for software design and development.