https://docs.microsoft.com/en-us/cli/azure/?view=azure-cli-latest
https://docs.microsoft.com/en-us/cli/azure/reference-index?view=azure-cli-latest
https://shell.azure.com/
az login -u <username> -p <password> az vm list --output=tsv | tr '\t' ',' az vm list --out tsv --query '[].[id, location, resourceGroup, name]' az vm run-command invoke --resource-group runcmd --name linux-runcmd --scripts "sudo touch /test.txt" --command-id RunShellScript az configure (config stored in /homedir/.azure/config)
Simple scripts to create Ububtu VM with nginx:
#!/bin/bash # Create a resource group. az group create --name myResourceGroup --location westeurope # Create a new virtual machine, this creates SSH keys if not present. az vm create --resource-group myResourceGroup --name myVM --image UbuntuLTS --generate-ssh-keys # Open port 80 to allow web traffic to host. az vm open-port --port 80 --resource-group myResourceGroup --name myVM # Use CustomScript extension to install NGINX. az vm extension set \ --publisher Microsoft.Azure.Extensions \ --version 2.0 \ --name CustomScript \ --vm-name myVM \ --resource-group myResourceGroup \ --settings '{"commandToExecute":"apt-get -y update && apt-get -y install nginx"}'
Azure Resource Manager — ARM uses json format. ARM files tend to be quite verbose and therefore long:
https://docs.microsoft.com/en-us/azure/azure-resource-manager/
https://azure.microsoft.com/en-us/resources/templates/
Can create infrastructure using portal then export ARM json file that can be used as template:
https://docs.microsoft.com/en-us/azure/azure-resource-manager/
https://azure.microsoft.com/en-us/resources/templates/
az group create --name <resource-group-name> --location <resource-group-location> az group deployment create --resource-group <my-resource-group> --template-uri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-vm-tags/azuredeploy.jsonhttps://github.com/Azure/azure-quickstart-templates/blob/master/101-vm-tags/azuredeploy.json
Can create infrastructure using portal then export ARM json file that can be used as template:
- Use portal to export
- Use CLI: az group export --name zrg > template
No comments:
Post a Comment