azure-cli-extensions icon indicating copy to clipboard operation
azure-cli-extensions copied to clipboard

spring-cloud extension doesn't accommodate specifying --subscription, resulting in errors

Open mkheck opened this issue 2 years ago • 15 comments

  • If the issue is to do with Azure CLI 2.0 in-particular, create an issue here at Azure/azure-cli

Extension name (the extension in question)

az spring-cloud

Description of issue (in as much detail as possible)


Most az and extension commands accept a --subscription parameter; az spring-cloud create does not. Problems arise when I try to create an Azure Spring Cloud instance using my "personal" Azure account, as it isn't possible to override my Microsoft corporate Azure account and the resource group I've just created with this command:

az group create -l $REGION -g $RESOURCE_GROUP --subscription $SUBSCRIPTION

use isn't visible to this command:

az spring-cloud create -n $SPRING_CLOUD_SERVICE -g $RESOURCE_GROUP -l $REGION --disable-app-insights false

This results in a script failure that I can't seem to work around. I've tried using az configure -d subscription=$SUBSCRIPTION and az configure -d account=$SUBSCRIPTION, but these don't change the outcome.

Please contact me via external or internal email/Teams if you need more info. Thanks.

mkheck avatar Feb 22 '22 19:02 mkheck

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @ShichaoQiu, @yuwzho, @yucwan.

Issue Details
  • If the issue is to do with Azure CLI 2.0 in-particular, create an issue here at Azure/azure-cli

Extension name (the extension in question)

az spring-cloud

Description of issue (in as much detail as possible)


Most az and extension commands accept a --subscription parameter; az spring-cloud create does not. Problems arise when I try to create an Azure Spring Cloud instance using my "personal" Azure account, as it isn't possible to override my Microsoft corporate Azure account and the resource group I've just created with this command:

az group create -l $REGION -g $RESOURCE_GROUP --subscription $SUBSCRIPTION

use isn't visible to this command:

az spring-cloud create -n $SPRING_CLOUD_SERVICE -g $RESOURCE_GROUP -l $REGION --disable-app-insights false

This results in a script failure that I can't seem to work around. I've tried using az configure -d subscription=$SUBSCRIPTION and az configure -d account=$SUBSCRIPTION, but these don't change the outcome.

Please contact me via external or internal email/Teams if you need more info. Thanks.

Author: mkheck
Assignees: -
Labels:

Service Attention, Spring Cloud

Milestone: -

ghost avatar Feb 22 '22 23:02 ghost

route to service team

yonzhan avatar Feb 22 '22 23:02 yonzhan

@mkheck Can you provide the detailed error message? The second command you mentioned didn't pass the --subscription parameter. Is this on purpose?

yuwzho avatar Feb 23 '22 02:02 yuwzho

Hi @yuwzho, the --subscription parameter doesn't exist for the az spring-cloud create command; that's basically the problem in a nutshell. 😞

Here are the commands & outputs interspersed. First thing below, I attempted to create the Azure Spring Cloud instance (after the az group create statement completed successfully and created the mh-scitc-rg group):

» az spring-cloud create -n $SPRING_CLOUD_SERVICE -g $RESOURCE_GROUP -l $REGION --disable-app-insights false Resource group 'mh-scitc-rg' could not be found.

Then I verified how I was logged in:

» az login The default web browser has been opened at https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize. Please continue the login in the web browser. If no web browser is available or if the web browser fails to open, use device code flow with az login --use-device-code. The following tenants require Multi-Factor Authentication (MFA). Use 'az login --tenant TENANT_ID' to explicitly login to a tenant. a3705fdd-ee80-4d55-93b8-fa3bb6915d4e 'Default Directory' No subscriptions found for [email protected]. jarvis :: azure/asc-mark/scripts ‹main*› » az account show 1 ↵ { "environmentName": "AzureCloud", "homeTenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47", "id": "0dbb7410-460a-4530-82ed-70039f35e357", "isDefault": true, "managedByTenants": [], "name": "ca-markheckler-demo-test", "state": "Enabled", "tenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47", "user": { "name": "[email protected]", "type": "user" } }

This indicates that there is an odd issue logging into my personal account ([email protected]), so it shows I'm still connected via my corporate account. This is a different issue, one I'm working with another team (please disregard).

I was in fact able to log into my personal account before and create the resource group under my account; I could see it via portal.azure.com in the browser. But without a --subscription parameter for the az spring-cloud create command, it simply defaults to my Microsoft account, searches for the resource group mh-scitc-rg under it, and fails.

I hope this helps. Apologies there are a couple of intersecting issues, but the missing --subscription parameter would both make the az spring-cloud create command consistent with the rest of the command portfolio I'm using in my scripts and (I believe) resolve the issue entirely.

My goal is to make these demos and others that build on them as failproof as possible for anyone, anywhere to be able to successfully use them to quickly and easily spin up Azure Spring Cloud deployments. Thank you very much for your help in that!

And please do contact me for any additional information you need.

mkheck avatar Feb 23 '22 05:02 mkheck

@mkheck The --subscription is a global argument for all az commands. If you type az spring-cloud create -h, you can see such text in the output. That means you can add the --subscription for the az spring-cloud create command and the spring cloud instance will be created under that subscription.

See Commands in an Azure subscription for more details. You can either use the --subscription for all az commands to set the subscription, or az account set -s <subscription> to set the default subscription for all az commands.

Global Arguments
    --debug                                                           : Increase logging verbosity
                                                                        to show all debug logs.
    --help -h                                                         : Show this help message and
                                                                        exit.
    --only-show-errors                                                : Only show errors,
                                                                        suppressing warnings.
    --output -o                                                       : Output format.  Allowed
                                                                        values: json, jsonc, none,
                                                                        table, tsv, yaml, yamlc.
                                                                        Default: json.
    --query                                                           : JMESPath query string. See
                                                                        http://jmespath.org/ for
                                                                        more information and
                                                                        examples.
    --subscription    <----------- HERE                               : Name or ID of subscription.    
                                                                        You can configure the
                                                                        default subscription using
                                                                        `az account set -s
                                                                        NAME_OR_ID`.
    --verbose                                                         : Increase logging verbosity.
                                                                        Use --debug for full debug
                                                                        logs.

yuwzho avatar Feb 23 '22 08:02 yuwzho

Hmm…Im fairly certain I tried that “manually” (outside of a script), but it’s possible I didn’t since it wasn’t in the docs. I do remember expanding and examining the “Global Arguments” section under the az spring-cloud create section to look for it. 🤔

Let me give it (another?) try and let you know shortly.

On Feb 23, 2022, at 02:23, Yuwei Zhou @.***> wrote:

 @mkheck The --subscription is a global argument for all az commands. If you type az spring-cloud create -h, you can see such text in the output. That means you can add the --subscription for the az spring-cloud create command and the spring cloud instance will be created under that subscription.

Global Arguments --debug : Increase logging verbosity to show all debug logs. --help -h : Show this help message and exit. --only-show-errors : Only show errors, suppressing warnings. --output -o : Output format. Allowed values: json, jsonc, none, table, tsv, yaml, yamlc. Default: json. --query : JMESPath query string. See http://jmespath.org/ for more information and examples. --subscription <----------- HERE : Name or ID of subscription.
You can configure the default subscription using az account set -s NAME_OR_ID. --verbose : Increase logging verbosity. Use --debug for full debug logs. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.

mkheck avatar Feb 23 '22 13:02 mkheck

Ok, some discoveries!

First, with regard to creating an Azure Spring Cloud instance: naming isn't considered unique to the resource group being used to create it, as it finds other AzSC instances in other accounts/RGs:

az spring-cloud create -n $SPRING_CLOUD_SERVICE -g $RESOURCE_GROUP -l $REGION --disable-app-insights false The service name 'mh-scitc-service' is already taken.

Second, the docs at https://docs.microsoft.com/en-us/cli/azure/spring-cloud?view=azure-cli-latest#az-spring-cloud-create do not indicate that --subscription is an optional or global parameter available for use, and using it doesn't change the outcome (see above).

Third...it now works. Without worrying about the absent --subscription parameter at all. Were you able to push a change or something? 🤔

I'll test this using the end-to-end script to see if it works; this test was manual. More news soon.

This raises another question, though: why does the az spring-cloud create command require a resource group to be specified if the AzSC instance isn't bounded by a resource group??

mkheck avatar Feb 23 '22 16:02 mkheck

  1. The azure spring cloud's name is global unique, because the name will be used in the fqdn for later runtime support.
  2. I will follow up the missing of subscription in the doc.
  3. As an Azure resource, Azure Spring Cloud instance must be put into an Azure Resource Group, you can see Manage Azure Resource Manager resource groups by using Azure CLI for the concept

@mkheck

yuwzho avatar Feb 24 '22 02:02 yuwzho

@zhoxing-ms For the 2nd issue, the genereted doc https://docs.microsoft.com/en-us/cli/azure/spring-cloud?view=azure-cli-latest#az-spring-cloud-create doesn't show --subscription neither in optional parameter nor global argument. I did a quick check for other services' documentation, and found the commands in azure-cli repo put the --subscription in the optional parameter, but none of commands only in the azure-cli-extension repo shows this parameter in documentation. Do you know is there any documentation configuration missing in this extension repo?

e.g. Commands in azure-cli repo have --subscription in doc https://docs.microsoft.com/en-us/cli/azure/storage/account?view=azure-cli-latest#az-storage-account-list-optional-parameters https://docs.microsoft.com/en-us/cli/azure/aks/nodepool?view=azure-cli-latest#az-aks-nodepool-list-optional-parameters Commands in azure-cli-extension repo don't have --subscription in doc https://docs.microsoft.com/en-us/cli/azure/elastic/monitor?view=azure-cli-latest#az-elastic-monitor-wait https://docs.microsoft.com/en-us/cli/azure/blockchain/member?view=azure-cli-latest#az-blockchain-member-create

yuwzho avatar Feb 24 '22 03:02 yuwzho

@daxianji007 Could you please help see why there is no description for global parameter --subscription in the document of CLI extension?

zhoxing-ms avatar Feb 24 '22 03:02 zhoxing-ms

Sure, I am checking the --subscription in the document. It could be related to this internal work item: https://ceapex.visualstudio.com/Engineering/_workitems/edit/521723

daxianji007 avatar Feb 25 '22 02:02 daxianji007

Update. We have fixed the AzureCLI Docs Pipeline. Now --subscription is generated for all commands. But it is folded in the page by default since it is in 'Global Parameters'

daxianji007 avatar Mar 25 '22 08:03 daxianji007

@mkheck let us know if you got the chance to verify the fix.

RakeshMohanMSFT avatar Jul 18 '22 06:07 RakeshMohanMSFT

Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

ghost avatar Jul 25 '22 08:07 ghost

Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

ghost avatar Aug 15 '22 08:08 ghost