Working with Azure App Services Web Apps, I learned how it's difficult to don't have integrated versioning of the configuration.
This is my solution.
My setup
It's always better to have a distributed system that requests/processes everything in parallel.
Nomad has the parameterized job type, it's one of my actual tools for this versioning.
I can run any command specifying parameters like the ones that I use:
- region_prefix
- environment_name
- component_name
- prefix
Using this type of job, I avoid redundancy… I always reuse the same job specification and I just need to run curl
or Nomad cli
in parallel to trigger the job for different Web Apps.
Another good solution is using a scheduler like Apache Airflow and a database with columnar compression (like PostgreSQL with columnar compression from Citus).
The neutral solution
A simple bash script, implementing a basic usage (= non-parallelized) with git for the versioning.
#!/bin/bash
WEBAPP_CONF() {
local region_prefix=$1
local environment_name="$2"
local component_name="$3"
local prefix="$4"
local resource_group_name="${region_prefix}-rg-syy-${environment_name}-app-wa"
local webapp_name="${region_prefix}-wac-syy-${environment_name}-app-${component_name}"
echo "Dumping $region_prefix $environment_name $component_name config"
az webapp config show --name "$webapp_name" --resource-group "$resource_group_name" >"$prefix"/"${environment_name}_${component_name}_webapp_config".json
az webapp config appsettings list --name "$webapp_name" --resource-group "$resource_group_name" >"$prefix"/"${environment_name}_${component_name}_webapp_config_appsettings".json
}
DEV() {
WEBAPP_CONF eaus dev sc1 DEV
WEBAPP_CONF eaus dev sc2 DEV
WEBAPP_CONF eaus dev sc3 DEV
}
QA() {
WEBAPP_CONF eaus qa sc1 QA
WEBAPP_CONF eaus qa sc2 QA
WEBAPP_CONF eaus qa sc3 QA
}
PREPROD() {
WEBAPP_CONF eaus preprod sc1 PREPROD
WEBAPP_CONF eaus preprod sc2 PREPROD
WEBAPP_CONF eaus preprod sc3 PREPROD
}
PROD() {
WEBAPP_CONF eaus prod sc1 PROD
WEBAPP_CONF eaus prod sc2 PROD
WEBAPP_CONF eaus prod sc3 PROD
}
GIT_COMMIT() {
local cmd_arg=$1
git add .
git commit -am "Auto-commit ($cmd_arg)"
git push
}
usage(){
echo "Usage: $0 <environment>"
echo " environment: all, dev, qa, preprod, prod"
exit 1
}
if [ "$#" -ne 1 ]; then
usage
fi
case "$1" in
all)
DEV
QA
PREPROD
PROD
GIT_COMMIT all
;;
dev)
DEV
GIT_COMMIT dev
;;
qa)
QA
GIT_COMMIT qa
;;
preprod)
PREPROD
GIT_COMMIT preprod
;;
prod)
PROD
GIT_COMMIT prod
;;
*)
usage
;;
esac