您现在访问的是微软AZURE全球版技术文档网站，若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站，请访问 https://docs.azure.cn.
Get started with Azure PowerShell
Azure PowerShell is designed for managing and administering Azure resources from the command line. Use Azure PowerShell when you want to build automated tools that use the Azure Resource Manager model. Try it out in your browser with Azure Cloud Shell, or install on your local machine.
This article helps you get started with Azure PowerShell and teaches the core concepts behind it.
Install or run in Azure Cloud Shell
The easiest way to get started with Azure PowerShell is by trying it out in an Azure Cloud Shell environment. To get up and running with Cloud Shell, see Quickstart for PowerShell in Azure Cloud Shell. Cloud Shell runs PowerShell 6 on a Linux container, so Windows-specific functionality isn't available.
When you're ready to install Azure PowerShell on your local machine, follow the instructions in Install the Azure PowerShell module.
Sign in to Azure
Sign in interactively with the
Connect-AzAccount cmdlet. Skip this step if you use Cloud Shell: Your Azure Cloud Shell session is already authenticated
for the environment, subscription, and tenant that launched the Cloud Shell session.
If you're in a non-US region, use the
-Environment parameter to sign in. Get the name of the environment for your region by using
the Get-AzEnvironment cmdlet. For example, to sign in to Azure China 21Vianet:
Connect-AzAccount -Environment AzureChinaCloud
In PowerShell 5.1 environments, you'll get a sign-in dialog to provide a username and password for your Azure account. On every other version of PowerShell, you'll get a token to use on [https://microsoft.com/devicelogin]. Open this page in your browser and enter the token, then sign in with your Azure account credentials and authorize Azure PowerShell.
After signing in, you'll see information indicating which of your Azure subscriptions is active. If you have multiple Azure subscriptions in your account and want to select a different one, get your available subscriptions with Get-AzSubscription and use the Set-AzContext cmdlet with your subscription ID. For more information about managing your Azure subscriptions in Azure PowerShell, see Use multiple Azure subscriptions.
Once signed in, use the Azure PowerShell cmdlets to access and manage resources in your subscription. To learn more about the sign-in process and authentication methods, see Sign in with Azure PowerShell.
Azure PowerShell cmdlets follow a standard naming convention for PowerShell,
VERB-NOUN. The verb describes the action (examples include
and the noun describes the resource type (examples include
AzVirtualNetworkGateway). Nouns in Azure PowerShell always start with the prefix
Az. For the full list of standard verbs, see Approved verbs for PowerShell Commands.
Knowing the nouns, verbs, and the Azure PowerShell modules available help you find commands with the Get-Command cmdlet. For example, to find all VM-related commands that use the
Get-Command -Verb Get -Noun AzVM* -Module Az.Compute
To help you find common commands, this table lists the resource type, corresponding Azure PowerShell module, and noun prefix to use with
|Resource type||Azure PowerShell module||Noun prefix|
For a full list of the modules in Azure PowerShell, see the Azure PowerShell modules list hosted on GitHub.
Learn Azure PowerShell basics with quickstarts and tutorials
To get started with Azure PowerShell, try an in-depth tutorial for setting up virtual machines and learning how to query them.
There are also Azure PowerShell quickstarts for other popular Azure services:
- Create a storage account
- Transfer objects to/from Azure Blob storage
- Create and retrieve secrets from Azure Key Vault
- Create an Azure SQL database and firewall
- Run a container in Azure Container Instances
- Create a Virtual Machine Scale Set (VMSS)
- Create a standard load balancer