0
0
Azurecloud~5 mins

Why automation matters in Azure - Why It Works

Choose your learning style9 modes available
Introduction
Automation helps you do repetitive cloud tasks quickly and without mistakes. It saves time and makes sure things work the same way every time.
When you need to create many virtual machines with the same settings.
When you want to update your cloud resources regularly without doing it by hand.
When you want to avoid human errors in setting up your cloud environment.
When you want to save time by running tasks automatically at scheduled times.
When you want to keep your cloud setup consistent across different teams.
Commands
This command creates a resource group in Azure where you can put your cloud resources. It is the first step to organize your resources.
Terminal
az group create --name example-resource-group --location eastus
Expected OutputExpected
{ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example-resource-group", "location": "eastus", "managedBy": null, "name": "example-resource-group", "properties": { "provisioningState": "Succeeded" }, "tags": {}, "type": "Microsoft.Resources/resourceGroups" }
--name - Specifies the name of the resource group.
--location - Specifies the Azure region where the group will be created.
This command creates a virtual machine in the resource group. It uses Ubuntu as the operating system and sets up SSH keys for secure access.
Terminal
az vm create --resource-group example-resource-group --name example-vm --image UbuntuLTS --admin-username azureuser --generate-ssh-keys
Expected OutputExpected
{ "fqdns": "", "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachines/example-vm", "location": "eastus", "name": "example-vm", "powerState": "VM running", "privateIpAddress": "10.0.0.4", "publicIpAddress": "52.170.12.34", "resourceGroup": "example-resource-group", "zones": "" }
--resource-group - Specifies the resource group where the VM will be created.
--name - Sets the name of the virtual machine.
--image - Chooses the operating system image for the VM.
--generate-ssh-keys - Automatically creates SSH keys for secure login.
This command lists all virtual machines in the resource group in a readable table format. It helps verify the VM was created.
Terminal
az vm list --resource-group example-resource-group -o table
Expected OutputExpected
Name ResourceGroup Location Zones PowerState ---------- -------------------- ---------- ------- ------------ example-vm example-resource-group eastus VM running
--resource-group - Filters the list to only show VMs in this group.
-o table - Formats the output as a table for easy reading.
Key Concept

If you remember nothing else from this pattern, remember: automation saves time and avoids mistakes by doing cloud tasks the same way every time.

Common Mistakes
Running commands manually every time instead of automating.
It wastes time and increases the chance of errors.
Use scripts or tools to automate repetitive cloud tasks.
Not specifying resource group or location when creating resources.
Resources may be created in unexpected places or fail to create.
Always specify resource group and location explicitly.
Ignoring output after running commands.
You might miss errors or important information about the resource status.
Always check command output to confirm success.
Summary
Create a resource group to organize your cloud resources.
Use commands to create virtual machines automatically with set options.
List and check your resources to confirm they are running as expected.