If you have an earlier version of the Azure PowerShell modules installed from the PowerShell Gallery and would like to update to the latest version, run the following commands in an elevated PowerShell session:
Update-Module-Name Az
Update-Module installs the new version side-by-side with previous versions. It does not uninstall the previous versions.
For detailed instructions on installing Azure PowerShell, please refer to the installation guide.
# Device Code login - Provides a link to sign into Azure via your web browserConnect-AzAccount# Service Principal login - Use a previously created service principal to log inConnect-AzAccount-ServicePrincipal -ApplicationId 'http://my-app'-Credential $PSCredential-TenantId $TenantId
To log into a specific cloud (AzureChinaCloud, AzureCloud, AzureGermanCloud, AzureUSGovernment), use the -Environment parameter:
# Specific cloud login - Logs into the Azure China cloudConnect-AzAccount-Environment AzureChinaCloud
Getting and setting your Azure PowerShell session context
A session context persists login information across Azure PowerShell modules and PowerShell instances. To view the context you are using in the current session, which contains the subscription and tenant, use the Get-AzContext cmdlet:
# Gets the Azure PowerShell context for the current PowerShell sessionGet-AzContext# Lists all available Azure PowerShell contexts in the current PowerShell sessionGet-AzContext-ListAvailable
To get the subscriptions in a tenant, use the Get-AzSubscription cmdlet:
# Get all of the Azure subscriptions in your current Azure tenantGet-AzSubscription# Get all of the Azure subscriptions in a specific Azure tenantGet-AzSubscription-TenantId $TenantId
To change the subscription that you are using for your current context, use the Set-AzContext cmdlet:
# Set the Azure PowerShell context to a specific Azure subscriptionSet-AzContext-Subscription $SubscriptionName-Name 'MyContext'# Set the Azure PowerShell context using pipingGet-AzSubscription-SubscriptionName $SubscriptionName|Set-AzContext-Name 'MyContext'
Use the Get-Command cmdlet to discover cmdlets within a specific module, or cmdlets that follow a specific search pattern:
# List all cmdlets in the Az.Accounts moduleGet-Command-Module Az.Accounts
# List all cmdlets that contain VirtualNetworkGet-Command-Name '*VirtualNetwork*'# List all cmdlets that contain VM in the Az.Compute moduleGet-Command-Module Az.Compute -Name '*VM*'
Cmdlet help and examples
To view the help content for a cmdlet, use the Get-Help cmdlet:
# View the basic help content for Get-AzSubscriptionGet-Help-Name Get-AzSubscription# View the examples for Get-AzSubscriptionGet-Help-Name Get-AzSubscription-Examples
# View the full help content for Get-AzSubscriptionGet-Help-Name Get-AzSubscription-Full
# View the help content for Get-AzSubscription on https://docs.microsoft.comGet-Help-Name Get-AzSubscription-Online
For detailed instructions on using Azure PowerShell, please refer to the getting started guide.
Reporting Issues and Feedback
Issues
If you find any bugs when using the Azure PowerShell modules, please file an issue in our GitHub issues page. Please fill out the provided template with the appropriate information.
Alternatively, be sure to check out the Azure Community Support if you have issues with the cmdlets or Azure services.
Feedback
If there is a feature you would like to see in Azure PowerShell, please use the Send-Feedback cmdlet, or file an issue in our GitHub issues page to provide the Azure PowerShell team direct feedback.
Azure PowerShell collects telemetry data by default. Microsoft aggregates collected data to identify patterns of usage to identify common issues and to improve the experience of Azure PowerShell. Microsoft Azure PowerShell does not collect any private or personal data.
For example, the usage data helps identify issues such as cmdlets with low success and helps prioritize our work.
While we appreciate the insights this data provides, we also understand that not everyone wants to send usage data. You can disable data collection with the Disable-AzDataCollection cmdlet. You can also read our privacy statement to learn more.
Azure/azure-powershell
This repository contains PowerShell cmdlets for developers and administrators to develop, deploy, and manage Microsoft Azure applications.
Try it out in Azure Cloud Shell!
Modules
Below is a table containing our Azure PowerShell rollup module.
Az
AzPreview
For a full list of modules found in this repository, please see the Azure PowerShell Modules document.
Installation
PowerShell Gallery
Run the following command in an elevated PowerShell session to install the rollup module for Azure PowerShell cmdlets:
This module runs on Windows PowerShell with .NET Framework 4.7.2 or greater, or the latest version of PowerShell 7. The
Az
module replacesAzureRM
. You should not installAz
side-by-side withAzureRM
.If you have an earlier version of the Azure PowerShell modules installed from the PowerShell Gallery and would like to update to the latest version, run the following commands in an elevated PowerShell session:
Update-Module
installs the new version side-by-side with previous versions. It does not uninstall the previous versions.For detailed instructions on installing Azure PowerShell, please refer to the installation guide.
Usage
Log into Azure
To connect to Azure, use the
Connect-AzAccount
cmdlet:To log into a specific cloud (AzureChinaCloud, AzureCloud, AzureGermanCloud, AzureUSGovernment), use the
-Environment
parameter:Getting and setting your Azure PowerShell session context
A session context persists login information across Azure PowerShell modules and PowerShell instances. To view the context you are using in the current session, which contains the subscription and tenant, use the
Get-AzContext
cmdlet:To get the subscriptions in a tenant, use the
Get-AzSubscription
cmdlet:To change the subscription that you are using for your current context, use the
Set-AzContext
cmdlet:For details on Azure PowerShell contexts, see our persisted credentials guide.
Discovering cmdlets
Use the
Get-Command
cmdlet to discover cmdlets within a specific module, or cmdlets that follow a specific search pattern:Cmdlet help and examples
To view the help content for a cmdlet, use the
Get-Help
cmdlet:For detailed instructions on using Azure PowerShell, please refer to the getting started guide.
Reporting Issues and Feedback
Issues
If you find any bugs when using the Azure PowerShell modules, please file an issue in our GitHub issues page. Please fill out the provided template with the appropriate information.
Alternatively, be sure to check out the Azure Community Support if you have issues with the cmdlets or Azure services.
Feedback
If there is a feature you would like to see in Azure PowerShell, please use the
Send-Feedback
cmdlet, or file an issue in our GitHub issues page to provide the Azure PowerShell team direct feedback.Contribute Code
If you would like to become an active contributor to this project, please follow the instructions provided in Microsoft Azure Projects Contribution Guidelines.
Additional information about contributing to this repository can be found in the
CONTRIBUTING.md
document and the Azure PowerShell Developer Guide document.Telemetry
Azure PowerShell collects telemetry data by default. Microsoft aggregates collected data to identify patterns of usage to identify common issues and to improve the experience of Azure PowerShell. Microsoft Azure PowerShell does not collect any private or personal data. For example, the usage data helps identify issues such as cmdlets with low success and helps prioritize our work. While we appreciate the insights this data provides, we also understand that not everyone wants to send usage data. You can disable data collection with the
Disable-AzDataCollection
cmdlet. You can also read our privacy statement to learn more.Learn More
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.