0
0
Azurecloud~5 mins

What is Azure - CLI Guide

Choose your learning style9 modes available
Introduction
Azure is a service that lets you use computers and storage over the internet instead of your own. It helps you run websites, store files, and use software without needing your own machines.
When you want to create a website that can handle many visitors without buying servers.
When you need to store backups safely and access them from anywhere.
When you want to run apps that can grow or shrink automatically based on users.
When you want to try new software without installing it on your computer.
When you want to connect your office computers to powerful cloud tools.
Commands
This command signs you into Azure so you can start using its services from the command line.
Terminal
az login
Expected OutputExpected
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code ABCD1234 to authenticate. You have logged in. Now let us find all the subscriptions to which you have access... [{ "cloudName": "AzureCloud", "homeTenantId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "id": "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy", "isDefault": true, "name": "Visual Studio Enterprise", "state": "Enabled", "tenantId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "user": { "name": "user@example.com", "type": "user" } }]
This command creates a container called a resource group where you can keep related Azure resources together in the East US region.
Terminal
az group create --name example-resource-group --location eastus
Expected OutputExpected
{ "id": "/subscriptions/yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy/resourceGroups/example-resource-group", "location": "eastus", "managedBy": null, "name": "example-resource-group", "properties": { "provisioningState": "Succeeded" }, "tags": {}, "type": "Microsoft.Resources/resourceGroups" }
--name - Sets the name of the resource group
--location - Specifies the Azure region for the resources
This command creates a virtual machine named example-vm inside the resource group, using Ubuntu Linux and setting up secure login keys.
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/yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy/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 to place the VM in
--name - Names the virtual machine
--image - Chooses the operating system image
--admin-username - Sets the admin user name for the VM
--generate-ssh-keys - Creates SSH keys for secure login
This command lists all virtual machines with details in a readable table format to check their status and IP addresses.
Terminal
az vm list -d -o table
Expected OutputExpected
Name ResourceGroup Location Zones PowerState PublicIP PrivateIP ----------- --------------------- ---------- ------- ------------ ------------- --------- example-vm example-resource-group eastus VM running 52.170.12.34 10.0.0.4
-d - Shows instance view details like power state
-o table - Formats output as a table
Key Concept

If you remember nothing else from Azure, remember: it lets you use powerful computers and storage over the internet so you don't need your own hardware.

Common Mistakes
Trying to use Azure commands without logging in first
Azure needs you to sign in to know who you are and what you can do
Always run 'az login' before other Azure commands
Creating resources without specifying a resource group
Azure organizes resources in groups; missing this causes errors or scattered resources
Use the --resource-group flag to keep resources organized
Not generating SSH keys when creating a Linux VM
Without SSH keys, you cannot securely connect to the VM
Use --generate-ssh-keys or provide your own keys during VM creation
Summary
Use 'az login' to sign into Azure from the command line.
Create a resource group to organize your cloud resources.
Launch virtual machines with specific images and secure access.
Check your virtual machines' status and IP addresses with a list command.