question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

az <resource> show has inconsistent exit status

See original GitHub issue

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..."
fi

az 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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
colemickenscommented, Jun 20, 2018

@williexu Thank you for cross-linking. I’m also quite happy with the decision. Cheers!

1reaction
yugangw-msftcommented, May 10, 2018

I read this and associated #6298, in short, 2 assumptions were involved leading to this change:

  1. show is supposed to be used as the existence check before create.
  2. all services could have consistencies on PUT, say, no error, fast, and support create if not exists, etc.

Both assumptions didn’t end up well. The first one is not always true as existence check can be used for other purposes. The second one has never happened. Also some commands fell through the crack that still throw. Lining up this inconsistency with the unconventional behavior thus causes the confusion on end users. In hindsight, we should not have done this change, or at least wait till the 2 assumptions got confirmed.

For how to address this issue, because the change has already been made and we have way more commands with this new behavior which makes the revert not a feasible option. So, let us just fix the rest commands to at least have the consistency. It sucks though to have to tweak such popular commands like az storage account show in a breaking change manner.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AZ cli version inconsistency - Visual Studio Feedback
When using the Azure CLI task (v2.*) in an Azure DevOps pipeline, the cli version is either 2.33.1 or 2.34.1. I am selecting...
Read more >
Troubleshooting Azure Windows VM extension failures
In this article we'll learn about troubleshooting some of the common VM extension failures. Viewing extension status. Azure Resource Manager ...
Read more >
Azure ARM API returns locations with inconsistent case
This behavior is inconsistent and causes issues with 3rd party tools when comparing or accessing resources in these regions.
Read more >
Error: Release code for Release group is inconsistent
I checked the release strategies and it shows an error: "Release code for Release group is inconsistent". The error message doesn't give any...
Read more >
Issues at a Glance: Full Practice Authority
What is it? Full Practice Authority (FPA) is the authorization of nurse practitioners (NPs) to evaluate patients, diagnose, order and interpret diagnostic ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found