We have 4 Azure environments for the stages of our development process; Dev, QA, UAT, Production. As you would expect, settings and options need to differ between environments, e.g., "apiurl": "http://dev-api.ourdomain.com" in dev needs to become "apiurl": "https://uat-api.ourdomain.com" for UAT.
At the moment we manually set these in the App Service Configuration page in the Azure Portal. There are problems with this method we are trying to overcome:
- It cannot be timed to happen with releases, it has to be manually done
- It's prone to human error
- Previous values are lost
- We cannot easily compare values between environments
- We cannot easily see which settings are no longer used
We would like to setup an appsettings.json with environment transforms for the differences. This addresses the last 3 issues as it will be stored in our code source control (if not secret), but this is useless if we cannot deploy that same file to set the Azure configuration. Pipeline steps might solve issues 1 and 2, but reintroduces issues 3 and 5.
Surely there is a simple way to do this that I am missing?
CodePudding user response:
I'd recommend creating the appsettings.json file in your source code, and use a pipeline to deploy the app service with it included; those settings will take effect. The pipeline can either adjust the file contents immediately before deployment, or upload the file as-is but also deploy app settings to override the file's contents.
This fits your requirements because:
- using a pipeline for automation gives you timing control (req 1) and reduces the risk of human error (req 2)
- keeping some of the settings in source control gives you a (partial) history of previous values (req 3)
- some of the settings may be the same across all environments; those can be left untouched in the appsettings.json, but those which differ can be overridden by the pipeline and adjusted correctly
- you could override settings by using a script task such as Powershell or a FileTransform task to actually change the appsettings.json
- or, you could override settings by automated configuration of the azure app service configuration, using the Azure CLI or an ARM Template for example.
For comparison of settings across the different environments (req 5), I'd recommend:
- organising your pipeline variables into different groups by environment, so the pipeline code makes it clear what the differences will be when deployed
- using azure cli or powershell commands to interrogate the actual deployed app services.
CodePudding user response:
The simple and the right way is to automate the deployment / release. Here's how to do it using Azure Devops:
https://docs.microsoft.com/en-us/azure/architecture/example-scenario/apps/devops-dotnet-webapp
https://docs.microsoft.com/en-us/azure/azure-app-configuration/push-kv-devops-pipeline
