Tools: how to create azure resources via azure cli

Tools: how to create azure resources via azure cli

1. Install Azure CLI & Login

Step-by-Step Installation:

3. Build a Virtual Network (VNet) & Subnet

4. Provision a Linux Virtual Machine

What's happening here?

5. Verify & Connect

Summary of Commands This guide provides a comprehensive walkthrough for setting up an Azure environment from your Mac. Whether you are prepping for a certification or building a personal lab, these steps will take you from a blank terminal to a running Linux server. On macOS, the most efficient way to manage the Azure CLI is through Homebrew. A Resource Group (RG) is a logical container. Deleting the RG later will automatically clean up all resources inside it, preventing "ghost" charges on your bill. Before you can drop a VM into Azure, you need a network. We will create a VNet and a Subnet simultaneously. Now, let's launch an Ubuntu 22.04 VM. This command handles the compute, creates a Public IP, and secures it with SSH keys. Once the command finishes, you will see a JSON output. Look for the publicIpAddress field. To connect from your Mac: If this is your first time connecting, type yes when asked about the authenticity of the host. Would you like me to provide a script to automatically shut down or delete these resources so you don't get charged when you're finished with your lab? Templates let you quickly answer FAQs or store snippets for re-use. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse

Command

Copy

$ -weight: 500;">brew -weight: 500;">update -weight: 500;">brew -weight: 500;">update -weight: 500;">brew -weight: 500;">update -weight: 500;">brew -weight: 500;">install azure-cli -weight: 500;">brew -weight: 500;">install azure-cli -weight: 500;">brew -weight: 500;">install azure-cli az account list --output table az account set --subscription "Your-Subscription-Name" az account list --output table az account set --subscription "Your-Subscription-Name" az account list --output table az account set --subscription "Your-Subscription-Name" az group create --name MyLabGroup --location eastus az group create --name MyLabGroup --location eastus az group create --name MyLabGroup --location eastus az network vnet create \ --resource-group MyLabGroup \ --name MyVNet \ --address-prefix 10.0.0.0/16 \ --subnet-name MySubnet \ --subnet-prefix 10.0.1.0/24 az network vnet create \ --resource-group MyLabGroup \ --name MyVNet \ --address-prefix 10.0.0.0/16 \ --subnet-name MySubnet \ --subnet-prefix 10.0.1.0/24 az network vnet create \ --resource-group MyLabGroup \ --name MyVNet \ --address-prefix 10.0.0.0/16 \ --subnet-name MySubnet \ --subnet-prefix 10.0.1.0/24 az vm create \ --resource-group MyLabGroup \ --name MyLinuxVM \ --image Ubuntu2204 \ --vnet-name MyVNet \ --subnet MySubnet \ --admin-username azureuser \ --generate-ssh-keys \ --public-ip-sku Standard az vm create \ --resource-group MyLabGroup \ --name MyLinuxVM \ --image Ubuntu2204 \ --vnet-name MyVNet \ --subnet MySubnet \ --admin-username azureuser \ --generate-ssh-keys \ --public-ip-sku Standard az vm create \ --resource-group MyLabGroup \ --name MyLinuxVM \ --image Ubuntu2204 \ --vnet-name MyVNet \ --subnet MySubnet \ --admin-username azureuser \ --generate-ssh-keys \ --public-ip-sku Standard ssh azureuser@<YOUR_PUBLIC_IP> ssh azureuser@<YOUR_PUBLIC_IP> ssh azureuser@<YOUR_PUBLIC_IP> - Open Terminal: Press Cmd + Space, type "Terminal," and hit Enter. - Update Homebrew: Ensure your package manager is current. - Install Azure CLI: - Login to Azure: Run the following command. It will automatically open your default web browser (Safari/Chrome). - Pro Tip: If your browser doesn't open or you are on a remote server, use az login --use-device-code. - Set your Subscription: If you have multiple accounts, list them and select the correct one: - --name: The identifier for your group. - --location: Choose a region close to you (e.g., eastus, westeurope, southeastasia). - 10.0.0.0/16: This is your private "building." - 10.0.1.0/24: This is a specific "room" (subnet) within that building where your VM will live. - --generate-ssh-keys: This is the "Magic Mac" flag. It looks in your ~/.ssh folder for a key; if it doesn't find one, it creates one for you automatically. - --public-ip-sku Standard: Assigns a static-capable IP so you can reach the machine from your laptop.