Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customer feedback | az group lock show | does not work without optional parameters #24457

Open
dbradish-microsoft opened this issue Oct 27, 2022 · 3 comments
Assignees
Labels
ARM az resource/group/lock/tag/deployment/policy/managementapp/account management-group Auto-Assign Auto assign by bot Azure CLI Team The command of the issue is owned by Azure CLI team feature-request
Milestone

Comments

@dbradish-microsoft
Copy link
Contributor

Query to all az group lock Issues
https://github.com/Azure/azure-cli/issues?q=is%3Aissue+is%3Aopen+group+lock+in%3Atitle%2Cbody+

Describe the bug
az group lock show does not work without optional parameters being supplied.

To Reproduce
az group lock show #fails with unexpected error
az group lock show -g MyResourceGroup #fails with unexpected error
az group lock show -g MyResourceGroup -n MyLockName #succeeds

Expected behavior
All group locks for the current active subscription should be listed as there is no concept of "current active lock". If RG and lockName are actually required, then we need to update our _params.py information.

Environment summary
Azure Cloud Shell

Autogen content link
https://learn.microsoft.com/en-us/cli/azure/group/lock?view=azure-cli-latest#az-group-lock-show

Screen print of test
image

@ghost ghost added Auto-Assign Auto assign by bot ARM az resource/group/lock/tag/deployment/policy/managementapp/account management-group labels Oct 27, 2022
@ghost ghost assigned zhoxing-ms Oct 27, 2022
@ghost ghost added this to the Backlog milestone Oct 27, 2022
@yonzhan yonzhan added Azure CLI Team The command of the issue is owned by Azure CLI team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Oct 27, 2022
@yonzhan
Copy link
Collaborator

yonzhan commented Oct 27, 2022

@zhoxing-ms for awareness

@zhoxing-ms
Copy link
Contributor

This is a common known issue. Because --name and --resource-group parameters need to be passed in at the same time, or only --ids parameters need to be passed in. So they are not required but have bound combination logic.
This is a problem encountered by all commands using id_part, so it may need to be solved at the azure-cli-core level in the future

@dbradish-microsoft
Copy link
Contributor Author

dbradish-microsoft commented Oct 28, 2022

@zhoxing-ms , I see four options for conditionally required parameters. You may have a 5th better idea. :-)

  1. Give this information in the command code block
  2. Use something other than square brackets to mean "optional if"
  3. Give this information in the example name property
  4. Give this information in the parameter description.

Here is an example of option #1: (not my preference. We want to keep this code block clean and simple moving all ad hoc tips and descriptions to Examples or Parameters.)

az group lock show [-ids]
                   [--resource-group] (is required if `ids` is not used)
                   [--lock-name] (is required if `ids` is not used)

Here is an example of option #2: For illustration, I am using () to mean "optional if" vs [] which means "always optional".

az group lock show (-ids)
                   (--resource-group)
                   (--lock-name)

Here is an example of option #3: (The easiest option in my opinion, but it leaves the command code block misleading with continued [] brackets.)
##Examples
Show a resource group level lock. Lock name and resource group are required if --ids is not used.

az group lock show -n lockname -g MyResourceGroup

Show the details of a resource group lock using the Id. The --resource-group and --name parameters are not needed in this example as these values exist in the Id.

az group lock show --ids /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Authorization/locks/MyLockName1

Here is an example of option #4: (This is the proper place for ad hoc tips and techniques.)

Optional Parameters

--ids
One or more resource IDs.... Required if --resource-group and --lock-name are not supplied.

--name
Name of the lock. Required if --resource-group is used.

--resource-group
Name of the resource group ... Required if --ids is not used.

@chasewilson , please share your opinion as this discussion has the potential to create a new best practice standard, or involve a new autogen update request.

@yonzhan yonzhan added feature-request and removed question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Nov 21, 2022
@dbradish-microsoft dbradish-microsoft changed the title az group lock show does not work without optional parameters Customer feedback | az group lock show | does not work without optional parameters Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ARM az resource/group/lock/tag/deployment/policy/managementapp/account management-group Auto-Assign Auto assign by bot Azure CLI Team The command of the issue is owned by Azure CLI team feature-request
Projects
None yet
Development

No branches or pull requests

3 participants