-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
Following template scripts generated from the Portal's Automation Script section, the CLI script uses checks for existing resources such as
az group show $resourceGroupName 1> /dev/null
if [ $? != 0 ]; then
echo "Resource group with name" $resourceGroupName "could not be found. Creating new resource group.."
set -e
(
set -x
az group create --name $resourceGroupName --location $resourceGroupLocation 1> /dev/null
)
else
echo "Using existing resource group..."
fiaz group show and az storage account show both return non-zero when the resource is missing and so the above pattern works. If being consistent across resources throughout my scripts, examples such as az storage share show and az vm show return zero regardless of the resource existing or not. Thus cannot be used to determine missing resources.
The issue is that the 'show' action doesn't always return a non-zero code for missing resources when used on other resource types. For consistency and approachability to new commands, I would thing these would behave the same across resources?
Environment summary
az --version 2.0.21
Python (Darwin) 3.6.3
Installed via homebrew