2
0
mirror of https://github.com/chubin/cheat.sheets synced 2024-11-19 03:25:44 +00:00
cheat.sheets/sheets/az
Igor Chubin 0adbf03348 Fix comment length in all first-level cheat sheets
*  sheets/MegaCli
*  sheets/az
*  sheets/azure
*  sheets/blktrace
*  sheets/emacs
*  sheets/exim
*  sheets/go
*  sheets/ipython
*  sheets/jq
*  sheets/nmap
*  sheets/perl
*  sheets/psql
*  sheets/redis
*  sheets/sed
*  sheets/smartctl
*  sheets/solidity
*  sheets/yq_v4
2020-11-22 13:10:48 +01:00

97 lines
2.9 KiB
Plaintext

# Microsoft Azure CLI 2.0
# Command-line tools for Azure
# Install Azure CLI 2.0 with one curl command.
curl -L https://aka.ms/InstallAzureCli | bash
# create a resource group named "MyRG" in the 'westus2' region
az group create -n MyRG -l westus2
# create a Linux VM using the UbuntuTLS image,
# with two attached storage disks of 10 GB and 20 GB
az vm create -n MyLinuxVM -g MyRG \
--ssh-key-value $HOME/.ssh/id_rsa.pub --image UbuntuLTS \
--data-disk-sizes-gb 10 20
# list VMs
az vm list --output table
# list only VMs having distinct state
az vm list -d --query "[?powerState=='VM running']" --output table
# delete VM (with the name MyLinuxVM in the group MyRG)
az vm delete -g MyRG -n MyLinuxVM --yes
# Delete all VMs in a resource group
az vm delete --ids $(az vm list -g MyRG --query "[].id" -o tsv)
# Create an Image based on a running VM
az vm deallocate -g MyRG -n MyLinuxVM
az vm generalize -g MyRG -n MyLinuxVM
az image create --resource-group MyRG --name MyTestImage --source MyLinuxVM
# Running VM based on a VHD
az storage blob upload --account-name "${account_name}" \
--account-key "${account_key}" --container-name "${container}" --type page \
--file "${file}" --name "${vhd}"
az disk create \
--resource-group "${resource_group}" \
--name myManagedDisk \
--source "https://${account_name}.blob.core.windows.net/${container}/${vhd}"
# open port
az vm open-port --resource-group MyRG --name MyLinuxVM --port 443 --priority 899
# Show storage accounts
az storage account list --output table
# Show contaniers for an account
az storage container list --account-name mystorageaccount --output table
# Show blobs in a container
az storage blob list --account-name mystorageaccount \
--container-name mycontainer --output table
# list account keys
az storage account keys list --account-name STORAGE_NAME --resource-group RESOURCE_GROUP
# Show own images
az image list --output table
# Configure default storage location
az configure --defaults location=eastus2
# Show disks
az disk list --output table
# Copy blob
az storage blob copy start \
--source-uri 'https://xxx.blob.core.windows.net/jzwuuuzzapn0/abcd?...' \
--account-key XXXXXXXXXX== \
--account-name destaccount \
--destination-container vms \
--destination-blob DESTINATION-blob.vhd
# List virtual networks
az network vnet list --output table
# List virtual networks adapters
az network nic list --output table
# List public IP addresses used by the VMs
az vm list-ip-addresses --output table
# create snapshot
az snapshot create --resource-group IC-EXASOL-001 --source vm1-disk1 -n vm1-snap1
# create SAS url for a snapshot
az snapshot grant-access --resource-group IC-EXASOL-001 --name vm1-snap1\
--duration-in-seconds 36000 --query '[accessSas]' -o tsv
# attach disk
az vm disk attach --vm-name vm1 -g RESOURCE_GROUP --disk DISK1_ID
# detach disk
az vm disk detach --vm-name vm1 -g RESOURCE_GROUP --name DISK1_ID