Requirements
Azure PowerShell works with PowerShell 5.1 or higher on Windows, or PowerShell Core 6.x and later on all platforms. If you aren't sure if you have PowerShell, or are on macOS or Linux, install the latest version of PowerShell Core.
To check your PowerShell version, run the command:
PowerShell
$PSVersionTable.PSVersion
To run Azure PowerShell in PowerShell 5.1 on Windows:
- Update to Windows PowerShell 5.1 if needed. If you're on Windows 10, you already have PowerShell 5.1 installed.
- Install .NET Framework 4.7.2 or later.
There are no additional requirements for Azure PowerShell when using PowerShell Core.
Install the Azure PowerShell module
Warning
You can't have both the AzureRM and Az modules installed for
PowerShell 5.1 for Windows at the same time. If you need to keep AzureRM
available on your system, install the Az module for PowerShell Core 6.x or
later. To do this, install
PowerShell Core 6.x or later and then follow these instructions
in a PowerShell Core terminal.
To install modules at a global scope, you need elevated privileges to install modules from the PowerShell Gallery. To install Azure PowerShell, run the following command in an elevated session ("Run as Administrator" on Windows, or with superuser privileges on macOS or Linux):
PowerShell
Install-Module -Name Az -AllowClobber
If you don't have access to administrator privileges, you can install for the current user by adding the
-Scope
argument.
PowerShell
Install-Module -Name Az -AllowClobber -Scope CurrentUser
By default, the PowerShell gallery isn't configured as a trusted repository for PowerShellGet. The first time you use the PSGallery you see the following prompt:
Output
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change
its InstallationPolicy value by running the Set-PSRepository cmdlet.
Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"):
Answer
Yes
or Yes to All
to continue with the installation.
The Az module is a rollup module for the Azure PowerShell cmdlets. Installing it downloads all of the available Azure Resource Manager modules, and makes their cmdlets available for use.
Troubleshooting
Here are some common problems seen when installing the Azure PowerShell module. If you experience a problem not listed here, please file an issue on GitHub.
Proxy blocks connection
If you get errors from
Install-Module
that indicate the PowerShell Gallery is unreachable, you may be behind a proxy. Different operating systems will have different requirements for configuring a system-wide proxy, which are not covered in detail here. Contact your system administrator for your proxy settings and how to configure them for your OS.
PowerShell itself may not be configured to use this proxy automatically. With PowerShell 5.1 and later, configure the proxy to use for a PowerShell session with the following command:
PowerShell
(New-Object System.Net.WebClient).Proxy.Credentials = `
[System.Net.CredentialCache]::DefaultNetworkCredentials
If your operating system credentials are configured correctly, this will route PowerShell requests through the proxy. In order to have this setting persist between sessions, add the command to aPowerShell profile.
In order to install the package, your proxy needs to allow HTTPS connections to the following address:
https://www.powershellgallery.com
Sign in
To start working with Azure PowerShell, sign in with your Azure credentials.
PowerShell
# Connect to Azure with a browser sign in token
Connect-AzAccount
Note:
If you've disabled
module autoloading, you need to manually import the module with
Import-Module Az. Because of the way the module is structured, this can
take a few seconds.
You'll need to repeat these steps for every new PowerShell session you start
Update the Azure PowerShell module
Because of how the Az module is packaged, the Update-Module command won't update your installation correctly. Az is technically a meta-module, encompassing all of the submodules that contain cmdlets to interact with Azure services. That means that to update the Azure PowerShell module, you will need to reinstall, rather than just update. This is done in the same way as installing, but you may need to add the
-Force
argument:
PowerShell
Install-Module -Name Az -AllowClobber -Force
Although this can overwrite installed modules, you may still have older versions left on your system. To learn how to remove old versions of Azure PowerShell from your system, see Uninstall the Azure PowerShell module.
Use multiple versions of Azure PowerShell
It's possible to install more than one version of Azure PowerShell. To check if you have multiple versions of Azure PowerShell installed, use the following command:
PowerShell
Get-InstalledModule -Name Az -AllVersions | select Name,Version
To remove a version of Azure PowerShell, see Uninstall the Azure PowerShell module.
You can install or load a specific version of the
Az
module by using the -RequiredVersion
argument:
PowerShell
# Install Az version 0.7.0
Install-Module -Name Az -RequiredVersion 0.7.0
# Load Az version 0.7.0
Import-Module -Name Az -RequiredVersion 0.7.0
If you have more than one version of the module installed, module autoload and
Import-Module
load the latest version by default.
No comments:
Post a Comment