LoginSignup
5
5

More than 5 years have passed since last update.

AzureCLIでコマンドを補完できるようにした件

Posted at

AzureCLIのGitリポジトリに書いてありました^^;;;

bash

azure --completion >> ~/azure.completion.sh
echo 'source ~/azure.completion.sh' >> ~/.bash_profile

zsh

echo '. <(azure --completion)' >> .zshrc

試してみる

$ azure lo
location  login     logout

おぉ、出た出た。

$ azure login -
--certificate-file   --json               --quiet              --tenant             --username           -e                   -q                   -v
--environment        --password           --service-principal  --thumbprint         --verbose            -p                   -u                   -vv

オプションもちゃんと候補が出てきました。
ウル覚えの時は役立ちそうです。

ただ、最初のうちはコマンドもオプションも手探りなので、

$ azure help
info:    Executing command help
info:             _    _____   _ ___ ___
info:            /_\  |_  / | | | _ \ __|
info:      _ ___/ _ \__/ /| |_| |   / _|___ _ _
info:    (___  /_/ \_\/___|\___/|_|_\___| _____)
info:       (_______ _ _)         _ ______ _)_ _
info:              (______________ _ )   (___ _ _)
info:
info:    Microsoft Azure: Microsoft's Cloud Platform
info:
info:    Tool version 0.9.15
help:
help:    Display help for a given command
help:      help [options] [command]
help:
help:    Log in to an Azure subscription using Active Directory or a Microsoft account identity.
help:      login [options]
help:
help:    Log out from Azure subscription using Active Directory. Currently, the user can log out only via Microsoft organizational account
help:      logout [options] [username]
help:
help:    Open the portal in a browser
help:      portal [options]
help:
help:    Commands:
help:      account        Commands to manage your account information and publish settings
help:      ad             Commands to display active directory objects
help:      apiapp         Commands to manage ApiApps
help:      availset       Commands to manage your availablilty sets
help:      config         Commands to manage your local settings
help:      datalake       Commands to manage your Data Lake objects
help:      feature        Commands to manage your features
help:      group          Commands to manage your resource groups
help:      hdinsight      Commands to manage HDInsight clusters and jobs
help:      insights       Commands related to monitoring Insights (events, alert rules, autoscale settings, metrics)
help:      keyvault       Commands to manage key vault instances in the Azure Key Vault service
help:      location       Commands to get the available locations
help:      network        Commands to manage network resources
help:      provider       Commands to manage resource provider registrations
help:      rediscache     Commands to manage your Azure Redis Cache(s)
help:      resource       Commands to manage your resources
help:      role           Commands to manage role definitions
help:      storage        Commands to manage your Storage objects
help:      tag            Commands to manage your resource manager tags
help:      usage          Command to view your aggregated Azure usage data
help:      vm             Commands to manage your virtual machines
help:      webapp         Commands to manage your Azure webapps
help:
help:    Options:
help:      -h, --help     output usage information
help:      -v, --version  output the application version
help:
help:    Current Mode: arm (Azure Resource Management)

で、コマンドが何系なのか見たり(コマンド文字列で想像はつきますが…)

$ azure login --help
help:    Log in to an Azure subscription using Active Directory or a Microsoft account identity.
help:
help:    Usage: login [options]
help:
help:    Options:
help:      -h, --help                            output usage information
help:      -v, --verbose                         use verbose output
help:      -vv                                   more verbose with debug output
help:      --json                                use json output
help:      -u --username <username>              user name or service principal ID. If multifactor authentication is required, you will be prompted to use the login command without parameters for interactive support.
help:      -e --environment [environment]        Environment to authenticate against, such as AzureChinaCloud; must support active directory.
help:      -p --password <password>              user password or service principal secret, will prompt if not given.
help:      --service-principal                   If given, log in as a service principal rather than a user.
help:      --certificate-file <certificateFile>  A PEM encoded certificate private key file.
help:      --thumbprint <thumbprint>             A hex encoded thumbprint of the certificate.
help:      --tenant <tenant>                     Tenant domain or ID to log into.
help:      -q --quiet                            do not prompt for confirmation of PII storage.
help:
help:    Current Mode: arm (Azure Resource Management)

で、オプション概要見たりになりそうな気はします。

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5