You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.6 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 "MyResourceGroup" in the westus2 region of Azure
az group create -n MyResourceGroup -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 MyResourceGroup --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 MyResourceGroup)
az vm delete -g MyResourceGroup -n MyLinuxVM --yes
# Delete all VMs in a resource group
az vm delete --ids $(az vm list -g MyResourceGroup --query "[].id" -o tsv)
# Create an Image based on a running VM
az vm deallocate -g MyResourceGroup -n MyLinuxVM
az vm generalize -g MyResourceGroup -n MyLinuxVM
az image create --resource-group MyResourceGroup --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_name}" --type page \
--file "${file}" --name "${vhd_name}"
az disk create \
--resource-group ${resource_group} \
--name myManagedDisk \
--source https://${account_name}.blob.core.windows.net/${container_name}/${vhd_name}
# open port
az vm open-port --resource-group MyResourceGroup --name MyLinuxVM --port 443 --priority 899