Coder Social home page Coder Social logo

azure / azure-cli Goto Github PK

View Code? Open in Web Editor NEW
3.9K 176.0 2.8K 568.56 MB

Azure Command-Line Interface

License: MIT License

Dockerfile 0.01% Python 98.99% Rich Text Format 0.01% Batchfile 0.01% Shell 0.05% PowerShell 0.03% HTML 0.01% Roff 0.87% JavaScript 0.01% C# 0.01% ANTLR 0.01% Jupyter Notebook 0.01% Bicep 0.01% TSQL 0.01% CSS 0.01% EJS 0.01%
azure azure-cli cloud

azure-cli's Introduction

Microsoft Azure CLI

Python Build Status Slack

A great cloud needs great tools; we're excited to introduce Azure CLI, our next generation multi-platform command line experience for Azure.

Take a test run now from Azure Cloud Shell!

Installation

Please refer to the install guide for detailed install instructions.

A list of common install issues and their resolutions are available at install troubleshooting.

Developer installation (see below)

Usage

$ az [ group ] [ subgroup ] [ command ] {parameters}

Get Started

Please refer to the "get started" guide for in-depth instructions.

For usage and help content, pass in the -h parameter, for example:

$ az storage -h
$ az vm create -h

Highlights

Here are a few features and concepts that can help you get the most out of the Azure CLI.

Azure CLI Highlight Reel

The following examples are showing using the --output table format, you can change your default using the az configure command.

Tab completion

We support tab-completion for groups, commands, and some parameters

# looking up resource group and name
$ az vm show -g [tab][tab]
AccountingGroup   RGOne  WebPropertiesRG

$ az vm show -g WebPropertiesRG -n [tab][tab]
StoreVM  Bizlogic

$ az vm show -g WebPropertiesRG -n Bizlogic

Query

You can use the --query parameter and the JMESPath query syntax to customize your output.

$ az vm list --query "[?provisioningState=='Succeeded'].{ name: name, os: storageProfile.osDisk.osType }"
Name                    Os
----------------------  -------
storevm                 Linux
bizlogic                Linux
demo32111vm             Windows
dcos-master-39DB807E-0  Linux

Exit codes

For scripting purposes, we output certain exit codes for differing scenarios.

Exit Code Scenario
0 Command ran successfully.
1 Generic error; server returned bad status code, CLI validation failed, etc.
2 Parser error; check input to command line.
3 Missing ARM resource; used for existence check from show commands.

Common scenarios and use Azure CLI effectively

Please check Tips for using Azure CLI effectively. It describes some common scenarios:

More samples and snippets

For more usage examples, take a look at our GitHub samples repo or https://docs.microsoft.com/cli/azure/overview.

Write and run commands in Visual Studio Code

With the Azure CLI Tools Visual Studio Code extension, you can create .azcli files and use these features:

  • IntelliSense for commands and their arguments.
  • Snippets for commands, inserting required arguments automatically.
  • Run the current command in the integrated terminal.
  • Run the current command and show its output in a side-by-side editor.
  • Show documentation on mouse hover.
  • Display current subscription and defaults in status bar.
  • To enable IntelliSense for other file types like .ps1 or .sh, see microsoft/vscode-azurecli#48.

Azure CLI Tools in Action

Data Collection

The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft's privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.

Telemetry Configuration

Telemetry collection is on by default. To opt out, please run az config set core.collect_telemetry=no to turn it off.

Reporting issues and feedback

If you encounter any bugs with the tool please file an issue in the Issues section of our GitHub repo.

To provide feedback from the command line, try the az feedback command.

[Microsoft internal] You may contact the developer team via [email protected].

Developer installation

Docker

We maintain a Docker image preconfigured with the Azure CLI. See our Docker tags for available versions.

$ docker run -u $(id -u):$(id -g) -v ${HOME}:/home/az -e HOME=/home/az --rm -it mcr.microsoft.com/azure-cli:<version>

Edge builds

If you want to get the latest build from the dev branch, you can use our "edge" builds.

You can download the latest builds by following the links below:

Package Link
MSI https://aka.ms/InstallAzureCliWindowsEdge
Homebrew Formula https://aka.ms/InstallAzureCliHomebrewEdge
Ubuntu Bionic Deb https://aka.ms/InstallAzureCliBionicEdge
Ubuntu Focal Deb https://aka.ms/InstallAzureCliFocalEdge
Ubuntu Jammy Deb https://aka.ms/InstallAzureCliJammyEdge
RPM el8 https://aka.ms/InstallAzureCliRpmEl8Edge

On Windows, you need to uninstall the official version before installing the edge build. (See #25607 (comment))

You can easily install the latest Homebrew edge build with the following command:

# You need to uninstall the stable version with `brew uninstall azure-cli` first
curl --location --silent --output azure-cli.rb https://aka.ms/InstallAzureCliHomebrewEdge
brew install --build-from-source azure-cli.rb

You can install the edge build on Ubuntu Jammy with the following command:

curl --location --silent --output azure-cli_jammy.deb https://aka.ms/InstallAzureCliJammyEdge && dpkg -i azure-cli_jammy.deb

And install the edge build with rpm package on RHEL 8 or CentOS Stream 8:

dnf install -y $(curl --location --silent --output /dev/null --write-out %{url_effective} https://aka.ms/InstallAzureCliRpmEl8Edge)

Here's an example of installing edge builds with pip3 in a virtual environment. The --upgrade-strategy=eager option will install the edge builds of dependencies as well.

$ python3 -m venv env
$ . env/bin/activate
$ pip3 install --pre azure-cli --extra-index-url https://azurecliprod.blob.core.windows.net/edge --upgrade-strategy=eager

To upgrade your current edge build pass the --upgrade option. The --no-cache-dir option is also recommended since the feed is frequently updated.

$ pip3 install --upgrade --pre azure-cli --extra-index-url https://azurecliprod.blob.core.windows.net/edge --no-cache-dir --upgrade-strategy=eager

The edge build is generated for each PR merged to the dev branch as a part of the Azure DevOps Pipelines.

Get builds of arbitrary commit or PR

If you would like to get builds of arbitrary commit or PR, see:

Try new features before release

Developer setup

If you would like to setup a development environment and contribute to the CLI, see:

Configuring Your Machine

Authoring Command Modules

Code Generation

Contribute code

This project has adopted the Microsoft Open Source Code of Conduct.

For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

If you would like to become an active contributor to this project please follow the instructions provided in Microsoft Open Source Guidelines.

azure-cli's People

Contributors

adewaleo avatar azuresdkci avatar bebound avatar brendandburns avatar burtbiel avatar calvinhzy avatar derekbekoe avatar djyou avatar evelyn-ys avatar fengzhou-msft avatar fumingzhang avatar haroldrandom avatar houk-ms avatar jiasli avatar jing-song avatar johanste avatar juliehzl avatar kairu-ms avatar marstr avatar mmyyrroonn avatar necusjz avatar panchagnula avatar qwordy avatar tjprescott avatar troydai avatar wangzelin007 avatar williexu avatar yugangw-msft avatar zengtaoxu avatar zhoxing-ms avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

azure-cli's Issues

list output and a missing newline

Shouldn't the final value in a TSV list end with a newline?

jasonsha@JasonShaMBP: ~/code/azure-cli $ az vm list --output tsv --query [].id

/subscriptions/ed268cc2-f790-402f-8a4e-402412d7b89f/resourceGroups/VSCODEACS/providers/Microsoft.Compute/virtualMachines/master1
/subscriptions/ed268cc2-f790-402f-8a4e-402412d7b89f/resourceGroups/VSCODEACS/providers/Microsoft.Compute/virtualMachines/master2jasonsha@JasonShaMBP: ~/code/azure-cli $

Long running operations need to keep quiet.

Long-running operations such as vm start use PoSH style progress reporting, which is super annoying in any sort of real scenario.

Consider
az vm list -g <resource-group> --query "[].name" --output tsv | xargs -I {} -P 10 az vm start -g <resource-group> --vm-name "{}"

You'll get a bizarre mish-mash of dots and gratuitous text. The desired behavior is to have the command print nothing and return an appropriate error code when the operation completes

"az help" should alias to "az --help"

<command> help is a standard pattern and particularly useful if you are new to the tool. In our case, az help prints a bunch of text that is decidedly unhelpful. For example, we say there is a -h option but don't describe its meaning. I recommend we alias "help" to --help for consistency with other tools.

$> az help
usage: az [-h] [--output {list,json,tsv}] [--query JMESPATH] {account,component,login,logout,network,resource,storage,taskhelp,vm} ... az: error: argument _command_package: invalid choice: 'help' (choose from 'account', 'component', 'login', 'logout', 'network', 'resource', 'storage', 'taskhelp', 'vm')

Remove az vm list-all and combine behavior with az vm list

It's quite confusing and cumbersome to have az vm list and az vm list-all. We should have az vm list which optionally accepts a resource group.

I understand why we have list and list-all today, but in practice it's incredibly confusing.

Commands don't handle unexpected parameters gracefully

Commands have strange behavior when unexpected parameters are provided. For example, 'azure vm list -rg' should return an error, but instead it makes a service call and reports a strange error:
The api-version '2015-06-15' is invalid. The supported versions are '2016-02-01,2015-11-01,2015-01-01,2014-04-01-preview,2014-04-01,2014-01-01,2013-03-01,2014-02-26,2014-04'.

az account set error

When entering 'az account set' it shows error info instead of usage info:

(env35) jasonsha@JasonShaMBP: ~/temp $ az account set
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/runpy.py", line 170, in _run_module_as_main
"main", mod_spec)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/jasonsha/code/azure-cli/src/azure/cli/main.py", line 24, in
sys.exit(azure.cli.main.main(args))
File "/Users/jasonsha/code/azure-cli/src/azure/cli/main.py", line 39, in main
cmd_result = app.execute(args)
File "/Users/jasonsha/code/azure-cli/src/azure/cli/application.py", line 81, in execute
result = args.func(converted_params)
File "/Users/jasonsha/code/azure-cli/src/command_modules/azure-cli-profile/azure/cli/command_modules/profile/account.py", line 48, in set_active_subscription
profile.set_active_subscription(subscription_id)
File "/Users/jasonsha/code/azure-cli/src/azure/cli/_profile.py", line 138, in set_active_subscription
subscription_id_or_name = subscription_id_or_name.lower()
AttributeError: 'NoneType' object has no attribute 'lower'

Bizarre statement completion behavior

The statement completion seems to have gotten wonky after argparse changes.

Type:
az vm jfskdljfs[tab]

We show the error text:
usage: az [-h] [--output {list,json,tsv}] [--query JMESPATH] {account,component,login,logout,network,resource,storage,taskhelp,vm} ... az: error: argument _command_package: invalid choice: 'ax' (choose from 'account', 'component', 'login', 'logout', 'network', 'resource', 'storage', 'taskhelp', 'vm')

But we should just do nothing if there is no match

tsv format for top-level resources should follow a consistent, useful pattern

Presently, list* verbs print out a pseudo-random format of values for tsv format:
az vm list -g cli-demo --output tsv None {object} {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/cli-demo/providers/Microsoft.Compute/virtualMachines/cli-demos None None westus cli-demos {object} {object} None Succeeded cli-demo 1 {object} None Microsoft.Compute/virtualMachines None {object} {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/cli-demo/providers/Microsoft.Compute/virtualMachines/cli-shell None None westus cli-shell {object} {object} None Succeeded cli-demo 1 {object} None Microsoft.Compute/virtualMachines

And for storage:
az vm list-all --output tsv None None {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/JOESVM/providers/Microsoft.Compute/virtualMachines/joesvm None None eastus joesvm {object} {object} None Succeeded JOESVM None {object} {object} Microsoft.Compute/virtualMachines None None {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/TEST/providers/Microsoft.Compute/virtualMachines/test None None eastus test {object} {object} None Succeeded TEST 1 {object} {object} Microsoft.Compute/virtualMachines None {object} {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/ARMAPP-INT7/providers/Microsoft.Compute/virtualMachines/disposalvm None None westus disposalvm {object} {object} None Succeeded ARMAPP-INT7 1 {object} None Microsoft.Compute/virtualMachines {object} None {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/ARMAPP-INT7/providers/Microsoft.Compute/virtualMachines/myarmappnix0 None None westus myarmappnix0 {object} {object} None Succeeded ARMAPP-INT7 None {object} {object} Microsoft.Compute/virtualMachines {object} None {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/ARMAPP-INT7/providers/Microsoft.Compute/virtualMachines/myarmappnix1 None None westus myarmappnix1 {object} {object} None Succeeded ARMAPP-INT7 None {object} {object} Microsoft.Compute/virtualMachines {object} None {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/ARMAPP-INT7/providers/Microsoft.Compute/virtualMachines/myarmappwin0 None None westus myarmappwin0 {object} {object} None Succeeded ARMAPP-INT7 None {object} {object} Microsoft.Compute/virtualMachines {object} {object} {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/ARMAPP-INT7/providers/Microsoft.Compute/virtualMachines/myarmappwin1 None None westus myarmappwin1 {object} {object} None Succeeded ARMAPP-INT7 1 {object} {object} Microsoft.Compute/virtualMachines {object} None {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/ARMAPP-INT8/providers/Microsoft.Compute/virtualMachines/myarmappnix0 None None westus myarmappnix0 {object} {object} None Succeeded ARMAPP-INT8 None {object} {object} Microsoft.Compute/virtualMachines {object} None {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/ARMAPP-INT8/providers/Microsoft.Compute/virtualMachines/myarmappnix1 None None westus myarmappnix1 {object} {object} None Succeeded ARMAPP-INT8 None {object} {object} Microsoft.Compute/virtualMachines {object} None {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/ARMAPP-INT8/providers/Microsoft.Compute/virtualMachines/myarmappwin0 None None westus myarmappwin0 {object} {object} None Succeeded ARMAPP-INT8 None {object} {object} Microsoft.Compute/virtualMachines {object} None {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/ARMAPP-INT8/providers/Microsoft.Compute/virtualMachines/myarmappwin1 None None westus myarmappwin1 {object} {object} None Succeeded ARMAPP-INT8 None {object} {object} Microsoft.Compute/virtualMachines None {object} {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/CLI-DEMO/providers/Microsoft.Compute/virtualMachines/cli-demos None None westus cli-demos {object} {object} None Succeeded CLI-DEMO 1 {object} None Microsoft.Compute/virtualMachines None {object} {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/CLI-DEMO/providers/Microsoft.Compute/virtualMachines/cli-shell None None westus cli-shell {object} {object} None Succeeded CLI-DEMO 1 {object} None Microsoft.Compute/virtualMachines

It takes a tremendous amount of mental column mapping to figure out, for example, which column contains the name--which is what you need in 99% of scenarios. I would propose that we follow a consistent pattern for all of these resources so you can always index the same column to get common properties such as the name, resource group, location, and id. The format that would make sense to me would follow the general convention of:
[resource group] [name] [location] [id] [... all other useful properties]

I would also recommend we never try to print complex objects since {object} isn't at all useful.

command: 'vm list' should show power state of VM (running, stopped, etc)

This is the field people cares a lot, and trigger different actions based on it
xplat's list command retrieves it using "get" with "instanceView" option enabled. I highly recommend cli's list should do the same, also it makes script easier to write.
I would imagine script to start a fleet vm would be like following

az vm list-all --query "[?contains(powerState,'stopped')==`true`].name" -o tsv | xargs -I {} -P 10 az vm start --vm-name "{}" -g mygroup

CLI Commands don't report error codes

The CLI needs to report meaningful error results for all commands to support any sort of scripting scenarios. I haven't found any commands that do this today. For example:
$> az vm list -g gogogog will fail with:
Resource group 'gogogog' could not be found.
$> echo $?
0

[AutoCommand] param --name picks up comments from all params with "name" in them

az vm create

--name param has description:
The name of the resource group. The name The name of the
deployment. Username for the Virtual Machine. The Virtual
Machine name. The subnet name. Name of virtual network to
add VM to.

I verified that the swagger has the correct comments--these comments come from all the params that have "name" in their param name

curl installation fails on new Ubuntu vm (even after installing pre-reqs)

It's important that installing the CLI on OSX & Ubuntu reliably works, particularly for clean/new machines or we're going to get a ton of negative feedback from partners.

Repro:
Create a new Azure VM with Ubuntu 14 LTS. Follow the installation instructions:

sudo apt-get update sudo apt-get install -y build-essential libssl-dev libffi-dev python3-dev curl http://azure-cli-nightly.cloudapp.net/install | sudo bash

It fails:
creating build/temp.linux-x86_64-2.7/c
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DUSE__THREAD -I/usr/include/ffi -I/usr/include/libffi -I/usr/include/python2.7 -c c/_cffi_backend.c -o build/temp.linux-x86_64-2.7/c/_cffi_backend.o
c/_cffi_backend.c:2:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------

Command "/usr/local/az/envs/default/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-PqLsoF/cffi/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-KKB5b0-record/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/az/envs/default/include/site/python2.7/cffi" failed with error code 1 in /tmp/pip-build-PqLsoF/cffi/
Traceback (most recent call last):
File "/tmp/azure_cli_install_tmp_ynhV", line 172, in
main()
File "/tmp/azure_cli_install_tmp_ynhV", line 161, in main
install_cli(env_dir)
File "/tmp/azure_cli_install_tmp_ynhV", line 99, in install_cli
env=dict(os.environ, AZURE_CLI_DISABLE_POST_INSTALL='1'))
File "/tmp/azure_cli_install_tmp_ynhV", line 63, in exec_command
check_call(command_list, cwd=cwd, env=env)
File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/local/az/envs/default/bin/pip', 'install', 'azure-cli==2016.04.26.nightly', '--extra-index-url', 'http://40.112.211.51:8080', '--trusted-host', '40.112.211.51']' returned non-zero exit status 1

tsv format for top-level resources should follow a consistent, useful pattern

Presently, list* verbs print out a pseudo-random format of values for tsv format:
az vm list -g cli-demo --output tsv None {object} {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/cli-demo/providers/Microsoft.Compute/virtualMachines/cli-demos None None westus cli-demos {object} {object} None Succeeded cli-demo 1 {object} None Microsoft.Compute/virtualMachines None {object} {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/cli-demo/providers/Microsoft.Compute/virtualMachines/cli-shell None None westus cli-shell {object} {object} None Succeeded cli-demo 1 {object} None Microsoft.Compute/virtualMachines

And for storage:
az vm list-all --output tsv None None {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/JOESVM/providers/Microsoft.Compute/virtualMachines/joesvm None None eastus joesvm {object} {object} None Succeeded JOESVM None {object} {object} Microsoft.Compute/virtualMachines None None {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/TEST/providers/Microsoft.Compute/virtualMachines/test None None eastus test {object} {object} None Succeeded TEST 1 {object} {object} Microsoft.Compute/virtualMachines None {object} {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/ARMAPP-INT7/providers/Microsoft.Compute/virtualMachines/disposalvm None None westus disposalvm {object} {object} None Succeeded ARMAPP-INT7 1 {object} None Microsoft.Compute/virtualMachines {object} None {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/ARMAPP-INT7/providers/Microsoft.Compute/virtualMachines/myarmappnix0 None None westus myarmappnix0 {object} {object} None Succeeded ARMAPP-INT7 None {object} {object} Microsoft.Compute/virtualMachines {object} None {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/ARMAPP-INT7/providers/Microsoft.Compute/virtualMachines/myarmappnix1 None None westus myarmappnix1 {object} {object} None Succeeded ARMAPP-INT7 None {object} {object} Microsoft.Compute/virtualMachines {object} None {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/ARMAPP-INT7/providers/Microsoft.Compute/virtualMachines/myarmappwin0 None None westus myarmappwin0 {object} {object} None Succeeded ARMAPP-INT7 None {object} {object} Microsoft.Compute/virtualMachines {object} {object} {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/ARMAPP-INT7/providers/Microsoft.Compute/virtualMachines/myarmappwin1 None None westus myarmappwin1 {object} {object} None Succeeded ARMAPP-INT7 1 {object} {object} Microsoft.Compute/virtualMachines {object} None {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/ARMAPP-INT8/providers/Microsoft.Compute/virtualMachines/myarmappnix0 None None westus myarmappnix0 {object} {object} None Succeeded ARMAPP-INT8 None {object} {object} Microsoft.Compute/virtualMachines {object} None {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/ARMAPP-INT8/providers/Microsoft.Compute/virtualMachines/myarmappnix1 None None westus myarmappnix1 {object} {object} None Succeeded ARMAPP-INT8 None {object} {object} Microsoft.Compute/virtualMachines {object} None {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/ARMAPP-INT8/providers/Microsoft.Compute/virtualMachines/myarmappwin0 None None westus myarmappwin0 {object} {object} None Succeeded ARMAPP-INT8 None {object} {object} Microsoft.Compute/virtualMachines {object} None {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/ARMAPP-INT8/providers/Microsoft.Compute/virtualMachines/myarmappwin1 None None westus myarmappwin1 {object} {object} None Succeeded ARMAPP-INT8 None {object} {object} Microsoft.Compute/virtualMachines None {object} {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/CLI-DEMO/providers/Microsoft.Compute/virtualMachines/cli-demos None None westus cli-demos {object} {object} None Succeeded CLI-DEMO 1 {object} None Microsoft.Compute/virtualMachines None {object} {object} /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/CLI-DEMO/providers/Microsoft.Compute/virtualMachines/cli-shell None None westus cli-shell {object} {object} None Succeeded CLI-DEMO 1 {object} None Microsoft.Compute/virtualMachines

It takes a tremendous amount of mental column mapping to figure out, for example, which column contains the name--which is what you need in 99% of scenarios. I would propose that we follow a consistent pattern for all of these resources so you can always index the same column to get common properties such as the name, resource group, location, and id. The format that would make sense to me would follow the general convention of:
[resource group] [name] [location] [id] [... all other useful properties]

I would also recommend we never try to print complex objects since {object} isn't at all useful.

CLI Outputs extra newlines to stdout

All of our commands seem to output unnecessary newlines, which can be problematic for some scripting scenarios and is generally just frowned upon. For example:
az vm list -g <resource-group> --output tsv > out.txt
Will include n + 1 lines of text, where n is the number of vms returned.

--help should use `less`

The standard behavior for explicit help is to use the less utility or equivalent paginator rather than simply dumping the help text to stdout. The reason for this is that it allows you to page through the help in a consistent fashion, then exit the help and return the terminal: your command history isn't scrolled off.

get-ip-addresses doesn't honor -g/--resourcegroup

If you call
az vm get-ip-addresses -g [somename]

You will get a list of all ip addresses for all VMs. It should filter out those inside the given resource group, as this is how all list commands are meant to work.

--expand parameter causes the CLI to timeout, send invalid requests, and generally does not work.

The --expand parameter seems to generally not work. For example,
az vm get --resourcegroup foo --vm_name bar --expand
will hang for a long time and then timeout:
Error occurred in request., RetryError: HTTPSConnectionPool(host='management.azure.com', port=443): Max retries exceeded with url: /subscriptions/172d64a6-0b5e-48e5-a735-fc2df7016da9/resourceGroups/test/providers/Microsoft.Compute/virtualMachines/test?api-version=2015-06-15&$expand= (Caused by ResponseError('too many 503 error responses',))

. If you pass a value for expand:
az vm get --resourcegroup foo --vm_name bar --expand statuses

An invalid request is sent:
The request URL is not valid.

help text for missing subcommands is not helpful

az vm usage usage: az vm usage [-h] {list} ... az vm usage: error: the following arguments are required: subcommand

This error message is hard to grock: we tell users that they are missing the "subcommand" argument but there is no argument called subcommand, of course. We should just tell them what subcommands are available. I get that if you know a lot about the CLI you can discern that '{list}' is the subcommand, but there's no real way to figure that out based on the text

azure vm image list-all functionality removed, but not added to az vm image list

(env35) jasonsha@JasonShaMBP: ~/code/azure-cli $ ./az vm image list
usage: az vm image list [-h] [--output {list,json,tsv}] [--query JMESPATH]
--location LOCATION --publisher-name PUBLISHER_NAME
--offer OFFER --skus SKUS [--filter FILTER]
[--top TOP] [--orderby ORDERBY]
az vm image list: error: the following arguments are required: --location/-l, --publisher-name, --offer, --skus

(env35) jasonsha@JasonShaMBP: ~/code/azure-cli $ ./az vm image list --help

Command
vm image list

Arguments
--location/-l [Required]: Location
--offer [Required]
--publisher-name [Required]
--skus [Required]
--filter : The filter to apply on the operation.
--help/-h : show this help message and exit
--orderby
--output/-o : Output format of type "list", "json" or "tsv"
--query : JMESPath query string. See http://jmespath.org/ for more
information and examples.
--top

az vm image list no longer returns urns

(env35) jasonsha@JasonShaMBP: ~/code/azure-cli $ ./az vm image list -l westus --publisher-name Canonical --offer UbuntuServer --skus 16.04.0-LTS --out json
[
{
"id": "/Subscriptions/ed268cc2-f790-402f-8a4e-402412d7b89f/Providers/Microsoft.Compute/Locations/westus/Publishers/Canonical/ArtifactTypes/VMImage/Offers/UbuntuServer/Skus/16.04.0-LTS/Versions/16.04.201604203",
"location": "westus",
"name": "16.04.201604203",
"tags": null
}
]

command: 'vm get' contains duplicate status fields under "list" format

az vm get -g XPLATTESTGEXTENSION5940 --vm-name xplatvmExt2778 --expand instanceView

produces the following instance status which 2 'code' fields, and 2 'Display Status' fields.

Instance View :
...omit...
Statuses :
Code : ProvisioningState/succeeded
Display Status : Provisioning succeeded
Level : Info
Message : None
Time : 2016-02-29T08:19:45.159744+00:00
Code : PowerState/running
Display Status : VM running
Level : Info
Message : None
Time : None

az account list error

Not sure when this stopped working...

(env35b) jasonsha@JasonShaMBP: ~/code/azure-cli $ az account list
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/runpy.py", line 170, in _run_module_as_main
"main", mod_spec)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/jasonsha/code/azure-cli/src/azure/cli/main.py", line 24, in
sys.exit(azure.cli.main.main(args))
File "/Users/jasonsha/code/azure-cli/src/azure/cli/main.py", line 31, in main
cmd_result = app.execute(args)
File "/Users/jasonsha/code/azure-cli/src/azure/cli/application.py", line 81, in execute
result = args.func(converted_params)
TypeError: list_subscriptions() missing 1 required positional argument: 'unexpected'
(env35b) jasonsha@JasonShaMBP: ~/code/azure-cli $

Access Tokens aren't refreshed

We need to handle refresh tokens to allow users to use the CLI for longer periods of time and avoid re-logging in after 1 hr:
msrestazure.azure_exceptions.CloudError: The access token expiry UTC time '3/10/2016 6:45:24 PM' is earlier than current UTC time '3/10/2016 6:45:38 PM'.

--help isn't always processed

az network vnet create --foo --help
This command should show help, however, argparse displays "--foo is missing a value". We should override this and show help whenever --help/-h is supplied

autocommand should handle multi-line comments

:param resource_group_name: The name of the resource group. The name
is case insensitive.

Expected comment: "The name of the resource group. The name is case insensitive."

Actual comment: " The name of the resource group. The name" (note extra space at beginning)

CLI dies if output pipe is broken.

If cli output is attached to a broken pipe, it will crash. Example: 'az vm list | jfhksfh'
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/runpy.py", line 170, in _run_module_as_main
"main", mod_spec)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/joe/azure-cli/src/azure/cli/main.py", line 5, in
sys.exit(azure.cli.main.main(sys.argv[1:]))
File "/Users/joe/azure-cli/src/azure/cli/main.py", line 47, in main
OutputProducer(formatter=formatter, file=file).out(cmd_result.result)
File "/Users/joe/azure-cli/src/azure/cli/_output.py", line 62, in out
print(self.formatter(obj), file=self.file)
BrokenPipeError: [Errno 32] Broken pipe

Install script defaults for .bashrc don't apply to OSX

Enable shell/tab completion? [y/N]: Y
Path to rc file (default /Users/jasonsha/.bashrc):
Traceback (most recent call last):
  File "/var/folders/5j/swc2q6dx5fg01399n9bz3swr0000gn/T/tmpEklOYl/completion_script", line 92, in <module>
    main()
  File "/var/folders/5j/swc2q6dx5fg01399n9bz3swr0000gn/T/tmpEklOYl/completion_script", line 85, in main
    backup_rc(rc_file_path)
  File "/var/folders/5j/swc2q6dx5fg01399n9bz3swr0000gn/T/tmpEklOYl/completion_script", line 51, in backup_rc
    except FileNotFoundError:
NameError: global name 'FileNotFoundError' is not defined

On OSX, only .bash_profile is called for Terminal. Should we check for the existence of .bashrc before using it as a default? Or maybe choose default based on current terminal or platform.

name/id parameters should be consistent

Our get commands use a verbose and inconsistent convention for the argument names. For example:
az availabilityset get --availability-set-name [name
az vm get --vm-name

These commands should all just use "name" since the name clearly pertains to the "get" noun. E.g.,
az vm get --name [name]

curl installation fails on new Ubuntu vm

After creating a new Ubuntu vm in Azure, I installed pip, the awscli, then ran:
curl http://azure-cli-nightly.cloudapp.net/install| bash

The installation fails:

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DUSE__THREAD -I/usr/include/ffi -I/usr/include/libffi -I/usr/include/python2.7 -c c/_cffi_backend.c -o build/temp.linux-x86_64-2.7/c/_cffi_backend.o
c/_cffi_backend.c:2:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------

Command "/usr/local/az/envs/default/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-M1aCGj/cffi/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-Mo3Img-record/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/az/envs/default/include/site/python2.7/cffi" failed with error code 1 in /tmp/pip-build-M1aCGj/cffi/
Traceback (most recent call last):
File "/tmp/azure_cli_install_tmp_Zs0h", line 164, in
main()
File "/tmp/azure_cli_install_tmp_Zs0h", line 158, in main
install_cli(env_dir)
File "/tmp/azure_cli_install_tmp_Zs0h", line 100, in install_cli
env=dict(os.environ, AZURE_CLI_DISABLE_POST_INSTALL='1'))
File "/tmp/azure_cli_install_tmp_Zs0h", line 64, in exec_command
check_call(command_list, cwd=cwd, env=env)
File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/local/az/envs/default/bin/pip', 'install', 'azure-cli==2016.04.19.nightly', '--extra-index-url', 'http://40.112.211.51:8080', '--trusted-host', '40.112.211.51']' returned non-zero exit status 1`

az vm size list vs. az vm list-sizes

az vm list-sizes -g JrsRg --vm-name JrsLinux
az vm size list -l westus

These two commands seem to have the same function (but do return slightly different data). Is this duplicated functionality? If so, list-sizes should win (noun with 1 verb)

Description of Username in "az login" is not right

It simply says "True"
az login

Arguments
--username/-u - True [Required]
--password/-p - user password or client secret, will prompt if not given.
--service-principal - the credential represents a service principal.
--tenant/-t - the tenant associated with the service principal.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.