English translation
Create resource group
AI Article Decision Snapshot
Turn the lesson into workflow, model, budget, and security checks before choosing tools.
Use this quick snapshot before leaving the article. It keeps the next search tied to practical AI software, model/API, cost, privacy, and implementation questions.
Workflow fit
Identify the real job behind the article: coding, research, document review, support, analytics, content, or internal automation.
Model or tool decision
Decide whether the next step is a software shortlist, an AI tool comparison, an API platform choice, or a model benchmark.
Budget and usage signal
Estimate seats, API calls, prompt volume, retries, review time, and fallback work before assuming the workflow is cheap.
Security and privacy review
Check whether source code, customer data, private documents, prompts, logs, or embeddings will enter the AI workflow.
In the previous article, we explored how to manage Azure resources using the Azure portal. The Azure portal provides an intuitive graphical user interface that enables users to easily create, manage, and monitor their Azure resources. However, for developers and system administrators, mastering command-line tools can significantly improve productivity and flexibility. This article therefore focuses on introducing the fundamental concepts of Azure CLI and Azure PowerShell, along with instructions for installing and using them to manage Azure resources.
Overview of Azure CLI and Azure PowerShell
Azure CLI
Azure CLI is a cross-platform command-line tool that allows users to interact with Azure resources via simple, concise commands. It runs on Windows, macOS, and Linux, and integrates well with various programming languages. With Azure CLI, users can efficiently perform bulk operations and automate tasks through scripting.
Azure PowerShell
Azure PowerShell is a command-line tool developed by Microsoft primarily for Windows users—especially those already familiar with PowerShell cmdlets. It provides a rich set of cmdlets designed specifically for managing Azure resources. PowerShell’s powerful scripting capabilities make it especially advantageous for handling complex automation workflows.
Installing Azure CLI and Azure PowerShell
Installing Azure CLI
Installation steps vary slightly across operating systems:
-
Windows:
- Download and run the installer from the Azure CLI installation page.
- Verify the installation by running
azin Command Prompt.
-
macOS:
- Install using Homebrew: execute
brew update && brew install azure-cli. - Verify the installation by running
azin Terminal.
- Install using Homebrew: execute
-
Linux:
- Install via your system’s package manager—for example,
sudo apt-get install azure-cli(for Debian/Ubuntu). - Verify the installation using the
azcommand.
- Install via your system’s package manager—for example,
Installing Azure PowerShell
-
Windows:
- Launch PowerShell and run:
Install-Module -Name Az -AllowClobber -Scope CurrentUser- Confirm successful installation with
Get-Module -ListAvailable Az.
macOS and Linux:
- You can also install Azure PowerShell on macOS and Linux by running the same command inside PowerShell.
Managing Resources with Azure CLI
Connecting to Your Azure Account
Before using Azure CLI, authenticate with your Azure account:
az login
This command opens your default browser, prompting you to enter your Azure credentials.
Creating a Resource Group
Creating a resource group is the foundational step for organizing Azure resources. Use the following command:
az group create --name MyResourceGroup --location eastus
Here, --name specifies the resource group name, and --location defines the Azure region (e.g., eastus).
Creating a Virtual Machine
Here's an example of deploying a simple virtual machine:
az vm create --resource-group MyResourceGroup --name MyVM --image UbuntuLTS --admin-username azureuser --generate-ssh-keys
The --image parameter selects the OS image—in this case, UbuntuLTS. The --generate-ssh-keys flag automatically generates SSH key pairs for secure access.
Managing Resources with Azure PowerShell
Connecting to Your Azure Account
To sign in to Azure from PowerShell:
Connect-AzAccount
Creating a Resource Group
Create a resource group using PowerShell:
New-AzResourceGroup -Name MyResourceGroup -Location "East US"
Note: Location names in PowerShell use full, space-separated region names (e.g., "East US"), unlike the hyphenated format (eastus) used in Azure CLI.
Creating a Virtual Machine
Example PowerShell command to deploy a VM:
New-AzVM -ResourceGroupName MyResourceGroup -Name MyVM -ImageName "UbuntuLTS" -Credential (Get-Credential)
The -Credential parameter triggers an interactive prompt for entering the administrator username and password.
Practical Example
Let’s walk through a real-world scenario demonstrating how Azure CLI and Azure PowerShell can automate common infrastructure provisioning tasks.
Suppose you want to create a resource group and deploy a web application VM within it.
Azure CLI Workflow:
# Create resource group
az group create --name MyWebAppGroup --location eastus
# Create VM
az vm create --resource-group MyWebAppGroup --name WebAppVM --image UbuntuLTS --admin-username azureuser --generate-ssh-keys
# Open HTTP port (80)
az vm open-port --port 80 --resource-group MyWebAppGroup --name WebAppVM
Azure PowerShell Workflow:
# Create resource group
New-AzResourceGroup -Name MyWebAppGroup -Location "East US"
# Create VM
$credential = Get-Credential
New-AzVM -ResourceGroupName MyWebAppGroup -Name WebAppVM -ImageName "UbuntuLTS" -Credential $credential
# Open HTTP port (80)
# Note: The example below is simplified; actual NSG configuration requires additional steps.
$vm = Get-AzVM -ResourceGroupName MyWebAppGroup -Name WebAppVM
$nic = Get-AzNetworkInterface -Name ($vm.NetworkProfile.NetworkInterfaces[0].Id.Split('/')[-1])
# Configure NSG rules as needed (full implementation omitted for brevity)
These examples illustrate how both Azure CLI and Azure PowerShell enable streamlined, repeatable, and scriptable Azure resource management.
Summary
In this article, we introduced the core concepts, installation procedures, and basic usage patterns of Azure CLI and Azure PowerShell. These command-line tools empower users to manage Azure resources more efficiently—particularly when performing bulk operations or building automated infrastructure workflows.
In the next tutorial, we’ll dive deeper into creating and configuring virtual machines—a foundational task in cloud infrastructure management.
Apply This Lesson
Turn this article into AI software, model, API, and security decisions.
English Article FAQ
Use this article as evidence before choosing AI tools
How should I use this AI Tutorials article?
Use it as the implementation or learning layer, then connect the idea to AI software buyer guides, tool comparisons, benchmarks, API choices, and security checks before making a production decision.
Is this English article different from the Chinese original?
The English edition is localized for global AI readers while preserving the original diagrams, screenshots, prompts, code examples, and source context from the Chinese article.
What should I read after Create resource group?
Continue with AI Software Buyer Guides, AI Tools Workbench, Best AI Coding Agents, AI Model Benchmarks, OpenAI vs Anthropic API, or LLM Security Tools depending on the decision you need to make.
Can this article alone choose an AI product or model?
No. Treat the article as evidence and context, then validate fit with pricing, privacy requirements, integration effort, benchmark results, workflow tests, and fallback planning.
Continue