This short post demonstrates how use the AZ-cli task in the DevOps pipeline to set the AppSettings of some UI Application that needs to connect to some REST Service.
Assuming that the service is already deployed the running pipeline deploys the UI application and finally runs the AZ-cli task (see code bellow) to set the ServiceUrl of the service in the AppSettings.
However, the pipeline has to first obtain the service url of the service named *MYRESTSERVICE and then to set AppSetting value of the UI application with the name MYAPPNAME
# get the webapi that contains 'MYRESTSERVICE'
$svcname = az webapp list --query "[?contains(name, 'MYRESTSERVICE')].[name]" -o tsv
$rg = az webapp list --query "[?contains(name, 'MYRESTSERVICE')].resourceGroup" -o tsv
Write-Host "MYRESTSERVICE:" $svcname
$uri =az webapp show --name $name -g $rg --query 'defaultHostName' --output tsv
Write-Host "MYRESTSERVICE Service Uri: " $uri
# Set the appsetting
az webapp config appsettings set -g $rg --name 'MYAPPNAME' --settings ServiceUrl=$uri