Skip to content

Commit 986ffbb

Browse files
committed
standardize on -az-cli URLs
1 parent cf09661 commit 986ffbb

16 files changed

Lines changed: 1038 additions & 1024 deletions

docs-ref-autogen/TOC.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# [Overview](../docs-ref-conceptual/overview.md)
2-
## [Install](../docs-ref-conceptual/install-az-cli2.md)
3-
## [Get started](../docs-ref-conceptual/get-started-with-az-cli2.md)
4-
## [Log in to Azure](../docs-ref-conceptual/authenticate-az-cli2.md)
5-
### [Log in with a service principal](../docs-ref-conceptual/create-an-azure-service-principal.md)
6-
## [Output formats](../docs-ref-conceptual/format-output-az-cli2.md)
7-
## [Query](../docs-ref-conceptual/query-az-cli2.md)
8-
## [Subscriptions](../docs-ref-conceptual/manage-azure-subscriptions.md)
9-
## [Release notes](../docs-ref-conceptual/release-notes.md)
2+
## [Install](../docs-ref-conceptual/install-az-cli.md)
3+
## [Get started](../docs-ref-conceptual/get-started-with-az-cli.md)
4+
## [Log in to Azure](../docs-ref-conceptual/authenticate-az-cli.md)
5+
### [Log in with a service principal](../docs-ref-conceptual/create-an-azure-service-principal-az-cli.md)
6+
## [Output formats](../docs-ref-conceptual/format-output-az-cli.md)
7+
## [Query](../docs-ref-conceptual/query-az-cli.md)
8+
## [Subscriptions](../docs-ref-conceptual/manage-azure-subscriptions-az-cli.md)
9+
## [Release notes](../docs-ref-conceptual/release-notes-az-cli.md)
1010
# Sample Scripts
1111
## [Virtual Machines](/azure/virtual-machines/virtual-machines-linux-cli-samples?toc=%2fcli%2fazure%2ftoc.json)
1212
## [Web Apps](/azure/app-service/app-service-cli-samples?toc=%2fcli%2fazure%2ftoc.json)

docs-ref-conceptual/TOC.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# [Overview](overview.md)
2-
## [Install](install-az-cli2.md)
3-
## [Get started](get-started-with-az-cli2.md)
4-
## [Log in to Azure](authenticate-az-cli2.md)
5-
### [Log in with a service principal](create-an-azure-service-principal.md)
6-
## [Output formats](format-output-az-cli2.md)
7-
## [Query](query-az-cli2.md)
8-
## [Subscriptions](manage-azure-subscriptions.md)
9-
## [Release notes](release-notes.md)
2+
## [Install](install-az-cli.md)
3+
## [Get started](get-started-with-az-cli.md)
4+
## [Log in to Azure](authenticate-az-cli.md)
5+
### [Log in with a service principal](create-an-azure-service-principal-az-cli.md)
6+
## [Output formats](format-output-az-cli.md)
7+
## [Query](query-az-cli.md)
8+
## [Subscriptions](manage-azure-subscriptions-az-cli.md)
9+
## [Release notes](release-notes-az-cli.md)
1010
# Sample Scripts
1111
## [Virtual Machines](/azure/virtual-machines/virtual-machines-linux-cli-samples?toc=%2fcli%2fazure%2ftoc.json)
1212
## [Web Apps](/azure/app-service/app-service-cli-samples?toc=%2fcli%2fazure%2ftoc.json)
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
title: Log in with Azure CLI 2.0
3+
description: Log in with Azure 2.0 CLI on Linux, Mac, or Windows.
4+
keywords: Azure CLI 2.0, Linux, Mac, Windows, OS X, Ubuntu, Debian, CentOS, RHEL, SUSE, CoreOS, Docker, Windows, Python, PIP
5+
author: allclark
6+
manager: douge
7+
ms.date: 02/27/2017
8+
ms.topic: article
9+
ms.prod: azure
10+
ms.technology: azure
11+
ms.assetid: 65becd3a-9d69-4415-8a30-777d13a0e7aa
12+
---
13+
14+
# Log in with Azure CLI 2.0
15+
16+
There are several ways to log in and authenticate with the Azure CLI. The simplest way to get started is to log in interactively through your browser, or to log in at the command line. Our recommended approach is to use service principals, which provide a way for you to create non-interactive accounts that you can use to manipulate resources. By granting just the appropriate permissions needed to a service principal, you can ensure your automation scripts are even more secure.
17+
18+
## Interactive log-in
19+
20+
Log in interactively from your web browser.
21+
22+
[!INCLUDE [interactive_login](includes/interactive-login.md)]
23+
24+
## Command line
25+
26+
Provide your credentials on the command line.
27+
28+
> This approach doesn't work with Microsoft accounts or accounts that have two-factor authentication enabled.
29+
30+
```azurecli
31+
az login -u <username> -p <password>
32+
```
33+
34+
## Logging in with a service principal
35+
36+
Service principals are like user accounts to which you can apply rules using Azure Active Directory.
37+
Authenticating with a service principal is the best way to secure the usage of your Azure resources
38+
from either your scripts or applications that manipulate resources.
39+
You define the roles you want your users to have via the `az role` set of commands.
40+
You can learn more and see examples of service principal roles in our [az role reference articles](https://docs.microsoft.com/cli/azure/role.md).
41+
42+
1. If you don't already have a service principal, [create one](create-an-azure-service-principal.md).
43+
44+
1. Log in with the service principal.
45+
46+
```azurecli
47+
az login --service-principal -u "http://my-app" -p <password> --tenant <tenant>
48+
```
49+
50+
To get your tenant, log in interactively and then get the tenantId from your subscription.
51+
52+
```azurecli
53+
az login
54+
az account show
55+
```
56+
57+
```json
58+
{
59+
"environmentName": "AzureCloud",
60+
"id": "********-****-****-****-************",
61+
"isDefault": true,
62+
"name": "Pay-As-You-Go",
63+
"state": "Enabled",
64+
"tenantId": "********-****-****-****-************",
65+
"user": {
66+
"name": "********",
67+
"type": "user"
68+
}
69+
}
70+
```
71+
Lines changed: 2 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,3 @@
11
---
2-
title: Log in with Azure CLI 2.0
3-
description: Log in with Azure 2.0 CLI on Linux, Mac, or Windows.
4-
keywords: Azure CLI 2.0, Linux, Mac, Windows, OS X, Ubuntu, Debian, CentOS, RHEL, SUSE, CoreOS, Docker, Windows, Python, PIP
5-
author: allclark
6-
manager: douge
7-
ms.date: 02/27/2017
8-
ms.topic: article
9-
ms.prod: azure
10-
ms.technology: azure
11-
ms.assetid: 65becd3a-9d69-4415-8a30-777d13a0e7aa
12-
---
13-
14-
# Log in with Azure CLI 2.0
15-
16-
There are several ways to log in and authenticate with the Azure CLI. The simplest way to get started is to log in interactively through your browser, or to log in at the command line. Our recommended approach is to use service principals, which provide a way for you to create non-interactive accounts that you can use to manipulate resources. By granting just the appropriate permissions needed to a service principal, you can ensure your automation scripts are even more secure.
17-
18-
## Interactive log-in
19-
20-
Log in interactively from your web browser.
21-
22-
[!INCLUDE [interactive_login](includes/interactive-login.md)]
23-
24-
## Command line
25-
26-
Provide your credentials on the command line.
27-
28-
> This approach doesn't work with Microsoft accounts or accounts that have two-factor authentication enabled.
29-
30-
```azurecli
31-
az login -u <username> -p <password>
32-
```
33-
34-
## Logging in with a service principal
35-
36-
Service principals are like user accounts to which you can apply rules using Azure Active Directory.
37-
Authenticating with a service principal is the best way to secure the usage of your Azure resources
38-
from either your scripts or applications that manipulate resources.
39-
You define the roles you want your users to have via the `az role` set of commands.
40-
You can learn more and see examples of service principal roles in our [az role reference articles](https://docs.microsoft.com/cli/azure/role.md).
41-
42-
1. If you don't already have a service principal, [create one](create-an-azure-service-principal.md).
43-
44-
1. Log in with the service principal.
45-
46-
```azurecli
47-
az login --service-principal -u "http://my-app" -p <password> --tenant <tenant>
48-
```
49-
50-
To get your tenant, log in interactively and then get the tenantId from your subscription.
51-
52-
```azurecli
53-
az login
54-
az account show
55-
```
56-
57-
```json
58-
{
59-
"environmentName": "AzureCloud",
60-
"id": "********-****-****-****-************",
61-
"isDefault": true,
62-
"name": "Pay-As-You-Go",
63-
"state": "Enabled",
64-
"tenantId": "********-****-****-****-************",
65-
"user": {
66-
"name": "********",
67-
"type": "user"
68-
}
69-
}
70-
```
71-
2+
redirect_url: authenticate-az-cli
3+
---
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
---
2-
redirect_url: authenticate-az-cli2
2+
redirect_url: authenticate-az-cli
33
---

docs-ref-conceptual/create-an-azure-service-principal.md renamed to docs-ref-conceptual/create-an-azure-service-principal-az-cli.md

File renamed without changes.
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
---
2+
title: Output formats for Azure CLI 2.0
3+
description: Use --output to format the output of Azure CLI 2.0 commands to tables, lists or json.
4+
keywords: Azure CLI 2.0, output, format, table, list, json, Linux, Mac, Windows, OS X
5+
author: allclark
6+
manager: douge
7+
ms.date: 02/27/2017
8+
ms.topic: article
9+
ms.prod: azure
10+
ms.technology: azure
11+
ms.assetid: 74bdb727-481d-45f7-a44e-15d18dc55483
12+
---
13+
14+
# Output formats for Azure CLI 2.0 commands
15+
16+
Azure CLI 2.0 uses json as its default output option, but offers various ways for you to format the output of any command. Use the `--output` (or `--out` or `-o`) parameter to format the output of the command into one of the output types noted in the following table.
17+
18+
--output | Description
19+
---------|-------------------------------
20+
`json` | json string. `json` is the default.
21+
`jsonc` | colorized json string.
22+
`table` | table with column headings.
23+
`tsv` | tab-separated values.
24+
25+
## Using the json option
26+
27+
The following example displays the list of virtual machines in your subscriptions in the default json format.
28+
29+
```azurecli
30+
az vm list --output json
31+
```
32+
33+
The results are in this form (only showing partial output for sake of brevity).
34+
35+
```json
36+
[
37+
{
38+
"availabilitySet": null,
39+
"diagnosticsProfile": null,
40+
"hardwareProfile": {
41+
"vmSize": "Standard_DS1"
42+
},
43+
"id": "/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/DEMORG1/providers/Microsoft.Compute/virtualMachines/DemoVM010",
44+
"instanceView": null,
45+
"licenseType": null,
46+
"location": "westus",
47+
"name": "DemoVM010",
48+
"networkProfile": {
49+
"networkInterfaces": [
50+
{
51+
"id": "/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/demorg1/providers/Microsoft.Network/networkInterfaces/DemoVM010VMNic",
52+
"primary": null,
53+
"resourceGroup": "demorg1"
54+
}
55+
]
56+
},
57+
...
58+
...
59+
...
60+
]
61+
```
62+
63+
## Using the table option
64+
65+
The table option provides an easy to read set of output, but note that nested objects are not included in the output with the simple `--output table`, unlike the preceding .json example. Using the same example with 'table' output format provides a curated list of most common property values.
66+
67+
```azurecli
68+
az vm list --out table
69+
```
70+
71+
```
72+
Name ResourceGroup Location
73+
----------- --------------- ----------
74+
DemoVM010 DEMORG1 westus
75+
demovm212 DEMORG1 westus
76+
demovm213 DEMORG1 westus
77+
KBDemo001VM RGDEMO001 westus
78+
KBDemo020 RGDEMO001 westus
79+
```
80+
81+
You can use the `--query` parameter to customize the properties and columns you want to show in the list output. The following example shows how to select just the VM Name and the Resource Group Name in the `list` command.
82+
83+
```azurecli
84+
az vm list --query "[].{ resource: resourceGroup, name: name }" -o table
85+
```
86+
87+
```
88+
Resource Name
89+
---------- -----------
90+
DEMORG1 DemoVM010
91+
DEMORG1 demovm212
92+
DEMORG1 demovm213
93+
RGDEMO001 KBDemo001VM
94+
RGDEMO001 KBDemo020
95+
```
96+
97+
## Using the tsv option
98+
99+
'tsv' output format returns a simple text-based and tab-separated output with no headings and dashes. This format makes it easy to consume the output into other commands and tools that need to process the text in some form. Using the preceding example with the `tsv` option outputs the tab-separated result.
100+
101+
```azurecli
102+
az vm list --out tsv
103+
```
104+
105+
```
106+
None None /subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/DEMORG1/providers/Microsoft.Compute/virtualMachines/DemoVM010 None None westus DemoVM010 None Succeeded DEMORG1 None Microsoft.Compute/virtualMachines cbd56d9b-9340-44bc-a722-25f15b578444
107+
None None /subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/DEMORG1/providers/Microsoft.Compute/virtualMachines/demovm212 None None westus demovm212 None Succeeded DEMORG1 None Microsoft.Compute/virtualMachines 4bdac85d-c2f7-410f-9907-ca7921d930b4
108+
None None /subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/DEMORG1/providers/Microsoft.Compute/virtualMachines/demovm213 None None westus demovm213 None Succeeded DEMORG1 None Microsoft.Compute/virtualMachines 2131c664-221a-4b7f-9653-f6d542fbfa34
109+
None None /subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/RGDEMO001/providers/Microsoft.Compute/virtualMachines/KBDemo001VM None None westus KBDemo001VM None Succeeded RGDEMO001 None Microsoft.Compute/virtualMachines 14e74761-c17e-4530-a7be-9e4ff06ea74b
110+
None None /subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/RGDEMO001/providers/Microsoft.Compute/virtualMachines/KBDemo02None None westus KBDemo020 None Succeeded RGDEMO001 None Microsoft.Compute/virtualMachinesed36baa9-9b80-48a8-b4a9-854c7a858ece
111+
```
112+
113+
The next example shows how the `tsv` output can be piped to commands like `grep` and `cut` to further parse specific values out of the `list` output. The `grep` command selects only items that have text "RGD" in them and then the `cut` command selects only the eighth field (separated by tabs) value to show in the output.
114+
115+
```azurecli
116+
az vm list --out tsv | grep RGD | cut -f8
117+
```
118+
119+
```
120+
KBDemo001VM
121+
KBDemo020
122+
```
123+
124+
## Setting the default output format
125+
126+
You can use the `az configure` command to set up your environment or establish preferences such as default settings for output formats. For common use, the easiest output format default is the "table" format - select **3** when prompted for output format choices.
127+
128+
```
129+
What default output format would you like?
130+
[1] json - JSON formatted output that most closely matches API responses
131+
[2] jsonc - Colored JSON formatted output that most closely matches API responses
132+
[3] table - Human-readable output format
133+
[4] tsv - Tab and Newline delimited, great for GREP, AWK, etc.
134+
Please enter a choice [3]:
135+
```

0 commit comments

Comments
 (0)