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

core: "az configure -d group=foo" doesn't apply when the group is an optional arg in the command #2703

Closed
chrisdias opened this issue Mar 31, 2017 · 12 comments
Milestone

Comments

@chrisdias
Copy link

I've got three different sites in three different resource groups:

~/.azure$ az appservice web list -o table
DefaultHostName                 Name          ResourceGroup    State    Location    AppServicePlan
------------------------------  ------------  ---------------  -------  ----------  -----------------
paluffopizza.azurewebsites.net  paluffopizza  paluffopizza-rg  Running  West US     WestUSPlan
springqbr.azurewebsites.net     SpringQBR     QBRDemoRG        Running  West US     thermocloud2-plan
thermocloud2.azurewebsites.net  thermocloud2  thermocloud2-rg  Running  West US     thermocloud2-plan

I want to use the new configure --defaults option to default the resource group, so following the docs here: https://docs.microsoft.com/en-us/cli/azure/#configure I did the following

~/.azure$ az configure -d group=paluffopizza-rg

Now my expectation is that whenever I run a command i can omit the resource group and it will default to what I have configured. Instead, I see all of the sites:

~/.azure$ az appservice web list -o table
DefaultHostName                 Name          ResourceGroup    State    Location    AppServicePlan
------------------------------  ------------  ---------------  -------  ----------  -----------------
paluffopizza.azurewebsites.net  paluffopizza  paluffopizza-rg  Running  West US     WestUSPlan
springqbr.azurewebsites.net     SpringQBR     QBRDemoRG        Running  West US     thermocloud2-plan
thermocloud2.azurewebsites.net  thermocloud2  thermocloud2-rg  Running  West US     thermocloud2-plan

What i expect to see is the same thing as running this command:

~/.azure$ az appservice web list -g paluffopizza-rg -o table
DefaultHostName                 Name          ResourceGroup    State    Location    AppServicePlan
------------------------------  ------------  ---------------  -------  ----------  ----------------
paluffopizza.azurewebsites.net  paluffopizza  paluffopizza-rg  Running  West US     WestUSPlan
@yugangw-msft
Copy link
Contributor

yugangw-msft commented Apr 3, 2017

It is by design at current moment, that the default is only applied when the resource-group is a mandatory field, which is not the case for appservice web list. If you try show command, the default will be picked up.

We debated on this, and decide not to apply everywhere, otherwise you will never be able to list webs across subscription.

I will leave this issue open for a while to accumulate a few more user voices.

@lostintangent
Copy link
Member

After using the defaults feature since it was released, I agree with @chrisdias. It's kind of strange to run a list command and not have it scoped to the default resource group.

@tjprescott
Copy link
Member

You could make the list commands accept --resource-group * to list all within the subscription. That wouldn't require much more logic but still allow you to use the default RG.

@lostintangent
Copy link
Member

@tjprescott I like that idea!

@derekbekoe
Copy link
Member

@tjprescott What happens when * is a valid parameter value?
What if the default you set just always applies (not just for required values).
If you want to list all in a subscription, you remove the default that you had set.

@yugangw-msft
Copy link
Contributor

It is feasible if we apply * only on appservice web list, but, we are losing the consistency with other list commands such as vm list. To touch vm list will force a breaking change, also it is a sign that the defaults feature is causing inconvenience on people which don't want to use the defaults.
Since we only have less than 10 commands, out of hundreds benefiting from the defaults, I would prefer to wait a bit to have more data and see more other potential issues before apply more tweaks. And yes maybe we would just always apply the defaults. And if a user does like to list artifacts across subscription, he needs to take a bit awkward process to temporarily remove and then add back the defaults.

@tjprescott
Copy link
Member

Is * ever a valid resource group? I would argue we'd apply * across all of our list/list-all folded commands.

@lostintangent
Copy link
Member

@yugangw-msft Irrespective if we add support for -g * or not, I'd vote to apply the defaults to all params (optional and required), since as this issue illustrates, the current behavior can be somewhat confusing.

@chrisdias
Copy link
Author

@lostintangent i agree, consistency is important here. Its confusing otherwise not knowing which commands support defaults and which do not.

@yugangw-msft
Copy link
Contributor

@chrisdias, the line is still clear, that when the group name is a mandatory field, the defaults will apply. If the group name is optional, that means the individual command has its own logic to handle that case, CLI doesn't step on its toe.

@chrisdias
Copy link
Author

Sorry, I guess its not clear to me when it is mandatory or not. For example, az appservice web list -h does not indicate that the resource group is optional and it tells me I can use the default group.

~/src$ az appservice web list -h

Command
    az appservice web list: List web apps.

Arguments
    --resource-group -g: Name of resource group. You can configure the default group using 'az
                         configure --defaults group=<name>'.

...

How do I know if it is required or not?

@yugangw-msft
Copy link
Contributor

yugangw-msft commented Apr 3, 2017

@chrisdias, Agreed it is a ui gap. The arg description is not correct here.

@yugangw-msft yugangw-msft added this to the Sprint 15 milestone Apr 3, 2017
@yugangw-msft yugangw-msft changed the title az configure -d group=foo doesn't seem to work? core: "az configure -d group=foo" doesn't apply when the group is optional and it is hard to tell Apr 3, 2017
@yugangw-msft yugangw-msft changed the title core: "az configure -d group=foo" doesn't apply when the group is optional and it is hard to tell core: "az configure -d group=foo" doesn't apply when the group is an optional arg in the command Apr 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants