> For the complete documentation index, see [llms.txt](https://www.devops.buzz/public/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.devops.buzz/public/azure/cli.md).

# CLI/Powershell

## Install on ubuntu

```
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
```

## az account

### List accounts

```bash
az account list
```

### List locations

```bash
az account list-locations
```

### Set account

```bash
az account set --subscription "YOUR SUBSCRIPTION"
```

## az network

### Get subnet ID

```
az network vnet subnet show -g YOUR-RG -n YOUR-SUBNET --vnet-name YOUR-VNET -otsv
```

## az resource

### List all resources

```bash
az resource list
```

```bash
Get-AzureRmResource
```

## az vm

### Force stop

```bash
az vm stop --resource-group YOUR-RG --name YOUR-VM-NAME --skip-shutdown
```

### Start

```bash
az vm start --resource-group YOUR-RG --name YOUR-VM-NAME
```

## Get object by ID

```bash
Get-AzureADObjectByObjectId -ObjectIds a183a290-4fa6-4a8f-b406-033429ec7119
```
