Azure CLI: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(17 intermediate revisions by the same user not shown)
Line 1: Line 1:
=External=
* https://docs.microsoft.com/en-us/cli/azure/
=Internal=
=Internal=
* [[Azure#Subjects|Azure]]
* [[Azure#Subjects|Azure]]
Line 9: Line 12:
brew install azure-cli
brew install azure-cli
</syntaxhighlight>
</syntaxhighlight>
=Login=
=Configuration=
{{External|https://docs.microsoft.com/en-us/cli/azure/authenticate-azure-cli}}
{{External|https://docs.microsoft.com/en-us/cli/azure/azure-cli-configuration}}
Azure CLI can be configured for settings such as default argument values, logging and data collection. The configuration can be performed with 'az configure', in a configuration file and environment variables. The configuration precedence is (from higher priority to lower priority):
* Command-line parameters
* Parameter persisted values set with 'az config param-persist'
* Environment variables
* Values in the configuration file set with 'az configure'
==Environment Variables==
===<tt>LOCATION</tt>===
The default [[Azure_Concepts#Location|location]] to use for all commands.
 
=CLI Options=
==-o==
<syntaxhighlight lang='bash'>
az [...] -o tsv [...]
</syntaxhighlight>
 
==--query==
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
az login
az aro show [...] --query "consoleProfile.url" -o tsv
</syntaxhighlight>
</syntaxhighlight>


The command starts a browser for authentication, and if the login is successful, shows something similar to:
=Operations=
<syntaxhighlight lang='text'>
==Version==
The default web browser has been opened at https://login.microsoftonline.com/common/oauth2/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`.
<syntaxhighlight lang='bash'>
You have logged in. Now let us find all the subscriptions to which you have access...
az version
[
  {
    "cloudName": "AzureCloud",
    "homeTenantId": "55555555-9999-4444-bbbb-aaaaaaaaaaaa",
    "id": "99999999-9999-9999-9999-999999999999",
    "isDefault": true,
    "managedByTenants": [],
    "name": "example.example.az(Converted to EA)",
    "state": "Enabled",
    "tenantId": "53ad779a-93e7-485c-ba20-ac8290d7252b",
    "tenantId": <same-as-homeTenantId>,
    "user": {
      "name": "some.user@example.com",
      "type": "user"
    }
  }
]
</syntaxhighlight>
</syntaxhighlight>
==Other Operations==
* [[Azure_Security_Operations#Login|Login]]
* [[Azure_Security_Operations#Login_Status_and_Account_Information|Login status and account information]]

Latest revision as of 00:42, 20 November 2020

External

Internal

Installation

https://docs.microsoft.com/en-us/cli/azure/install-azure-cli
https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-macos

Homebrew

brew install azure-cli

Configuration

https://docs.microsoft.com/en-us/cli/azure/azure-cli-configuration

Azure CLI can be configured for settings such as default argument values, logging and data collection. The configuration can be performed with 'az configure', in a configuration file and environment variables. The configuration precedence is (from higher priority to lower priority):

  • Command-line parameters
  • Parameter persisted values set with 'az config param-persist'
  • Environment variables
  • Values in the configuration file set with 'az configure'

Environment Variables

LOCATION

The default location to use for all commands.

CLI Options

-o

az [...] -o tsv [...]

--query

az aro show [...] --query "consoleProfile.url" -o tsv

Operations

Version

az version

Other Operations