I found a solution. It is so simple when you know it.
- Make sure the Dockerfile has Azure CLI
- In the entrypoint/cmd for the Dockerfile reference a bash script
- In the bash script use Azure CLI to sign in and receive an access token
- Use the access token to sign in.
I got stuck at 3 before because I was unaware of the --identity option. And for this to work in any container app (job), you will need to use the workaround of export APPSETTING_WEBSITE_SITE_NAME=DUMMY
for az login --identity
to work properly. Why? See this issue https://github.com/Azure/azure-cli/issues/22677
Example bash script.
#!/bin/bash
# Workaround to get az login --identity to use the correct url for authentication
export APPSETTING_WEBSITE_SITE_NAME=DUMMY
# Get access token and username
az login --identity
token=$(az account get-access-token --resource https://database.windows.net/ --query accessToken -o tsv)
username=$(az ad signed-in-user show --query userPrincipalName --output tsv)
# Example Setup your jbdc url
jdbc=jdbc:postgresql://[server]:5432/[database]
# Run liquibase with token
liquibase update --username $username --password $token --url $jdbc