The background to this is I am working on warm HA support for our product deployed in Azure. The code depends on Azure CLI. I am looking for the answer to the following question.
Is there a way in Azure CLI to specify that a certain subnet update operation should only be applied if the etag of the subnet resource has a certain value ?
something like ‘az network vnet subnet update -n XXX -g YYY –vnet-name ZZZ –route-table WWW’ but specifying an etag value to decide if the update should take place or not.
Subnet operations do not use the –if-match parameter unfortunately. This code is ugly and susceptible to race conditions:
# Get current subnet configuration
current_subnet=$(az network vnet subnet show -g YYY --vnet-name ZZZ -n XXX)
# Extract the etag
current_etag=$(echo $current_subnet | jq -r '.etag')
# Compare etag (replace 'expected_etag' with your value)
if [ "$current_etag" == "expected_etag" ]; then
# Proceed with update
az network vnet subnet update -n XXX -g YYY --vnet-name ZZZ --route-table WWW
else
echo "Etag mismatch, update skipped"
fi
Mittskataz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.