Configure PowerShell For Microsoft Azure Az Module
Today, somehow my Window PowerShell crashed for Azure modules and I had a plan to write an article on Azure Storage Account which based on powershell command and because of this issue, I could not proceed instead busy with repairing/ reinstalling my powershell modules. Initially I thought it would be very simple to install those modules but I had to search and put some good amount of efforts to make it possible. So I thought why not put these restore efforts into one article !!!. Therefore am I writing this small article with some good screenshots and some basic concept, which will be helpful for beginners.
Initially, Windows PowerShell was built on the .NET Framework and only worked on Windows systems. As time passed, the PowerShell version get updated and in the current release, PowerShell uses .NET 5.0 as its runtime. PowerShell runs on Windows, macOS, and Linux platforms. PowerShell is an Open Source project on GitHub.
For cloud, on-premises, and hybrid environments, PowerShell 7 is packed with enhancements and new features. PowerShell 7 works side-by-side with other Windows PowerShell version (5.1). PowerShell 7 is supported on the following Windows operating systems:
- Windows 8.1 and 10
- Windows Server 2012, 2012 R2, 2016, and 2019
Let’s check our PowerShell version by using following command and the result as shown in the following figure.
As we can see we have PowerShell Version 5 so let’s install PowerShell version 7.x. Download latest PowerShell-7.1.3-win-x64.msi file from here and once downloaded the package, start installation as showing and guiding in the following series of figures.
As showing in the above figure we have successfully install PowerShell 7.x. Following Microsoft articles sharing more information on installing PowerShell on various supported and experimental platforms.
- Installing PowerShell on Windows
- Installing PowerShell on Linux
- Installing PowerShell on macOS
- Installing PowerShell on ARM
Azure PowerShell :
Azure PowerShell is a set of cmdlets which manage Azure resources directly from the PowerShell command line. Azure PowerShell is designed to make it easy to learn and get started with, but provides powerful features for automation. Written in .NET Standard, Azure PowerShell works with PowerShell 5.1 on Windows, and PowerShell 7.x and higher on all platforms.
Azure Az PowerShell module :
Initially PowerShell supported AzureRM module. Now all versions of the AzureRM PowerShell module are outdated and it is replaced by Azure Az PowerShell module . The Az PowerShell module is a set of cmdlets for managing Azure resources directly from PowerShell. PowerShell provides powerful features for automation that can be leveraged for managing your Azure resources. Microsoft Azure PowerShell does not collect any private or personal data.
Supported Features Of Azure Az Module :
Following are the list of benefits provided by Az powershell module features. Got this information from Microsoft documents.
Security and stability
- Token cache encryption : To secure user’s token in cache from miss use of the token.
- Prevention of man-in-the-middle (MITM) attack type : Where the attacker secretly relays and possibly alters the communications between two parties who believe that they are directly communicating with each other.
- Support authentication with ADFS 2019 :
- Username and password authentication in PowerShell 7:
- Support for features like continuous access evaluation (coming in 2021)
Support for all Azure services
- All generally available Azure services have a corresponding supported PowerShell module : Robust support for all azure services.
- Multiple bug fixes and API version upgrades since AzureRM : Continuous improvement in APIs.
- Support in Cloud Shell and cross-platform :
- Can get and use access token to access Azure resources :
- Cmdlet available for advanced REST operations with Azure resources :
Install Azure Az PowerShell module :
In this section we will explains how to install the Azure Az PowerShell module using PowerShellGet but before that let check if we have PowerShellGet ready in our environment as it comes along with window.
Step 1 – Open Windows PowerShell as an admin and run following command to install the latest NuGet provider.
Install-PackageProvider -Name NuGet -Force
Step 2 – Now, we need to check if we have any existing version of PowerShellGet on our machine. To check run following comand.
Install-Module -Name PowerShellGet -Force
To upgrade the PowerSellGet version run following command.
Update-Module -Name PowerShellGet
Step 3 – We are ready to install Az module by using the Install-Module cmdlet. Which is the preferred installation method for the Az PowerShell module. Install the Az module for the current user only as it is recommended by Microsoft and this is applicable for all OS it supported. Let’s execute following cmdlet.
Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force
Step 4 – Use following command to connect Azure subscription.
Now we are ready with our powershell environment and we can do all operations from PowerShell 7.x .
In our next article, we will discuss How to configure/Install Azure CLI.
I hope this is informative to you. Please let me know if I missed anything important or if my understanding is not up to the mark.
Keep reading, share your thoughts, experiences. Feel free to contact us to discuss more.
If you have any suggestion / feedback / doubt, you are most welcome. Stay tuned on Knowledge-Junction, will come up with more such articles.
Thanks for reading 🙂 .