Member-only story

Azure CLI example

Maciej
2 min readSep 24, 2020

--

Introduction

This is a note of things that are often used in the Azure CLI. There is also the operation of Azure resources by CLI, so install the CLI for each OS.

Command example

For example, running it in PowerShell launches a browser, from which you log in with your Azure account.

The following is an example of execution in PowerShell. (However, each ID has been changed to an appropriate value.) The value of homeTenantId corresponds to the tenant ID of the specified directory.

PS C:\Users\user> az login
You have logged in. Now let us find all the subscriptions to which you have access...
The following tenants don't contain accessible subscriptions. Use 'az login --allow-no-subscriptions' to have tenant level access.
b5c0fe9f-a254-4728-a740-dc1d25d92c18
267f1a06-a596-43fc-828a-67547938399f
[
{
"cloudName": "AzureCloud",
"homeTenantId": "d4278972-2b8a-4be6-9011-846db11ae6c6",
"id": "5539a220-9e9a-402a-a75b-1edef17e99ef",
"isDefault": true,
"managedByTenants": [],
"name": "subsc1",
"state": "Enabled",
"tenantId": "f321d4ad-6443-4991-9775-fa558b1a384b",
"user": {
"name": "user@example.com",
"type": "user"
}
}
]
PS C:\Users\user>

Subscription

View subscription list

az account list --output table
az account list -o table

Resource group

View a list of resource groups in your subscription

az group list --output table

Create a resource group in your subscriptionCreate a resource group in your subscription.

az group create  --name <resource-group-name> --location <resource-group-location>

Resource

Display resource list in resource group (specify resource type as an option)

--

--

Maciej
Maciej

Written by Maciej

DevOps Consultant. I’m strongly focused on automation, security, and reliability.

No responses yet

Write a response