In Which Operating System Can We Use Azure Powershell?
- Azure PowerShell can be used in any operating system.
- Windows provides support for Azure PowerShell from Windows 7.
- In operating systems like Linux OS and Mac OS, which don't have a PowerShell, we need to install PowerShell Core, an edition of PowerShell with cross-platform support.
To install Powershell Core in Ubuntu, we just need to install the pre-requisite packages, download the GPG keys(Gnu Privacy Guard), an encryption algorithm, and register the keys to use them. Then we can download PowerShell with the apt-get command. The script below is used to download PowerShell on ubuntu(Linux),
Then we can use the following command to create a Powershell session,
- Microsoft recommends a version of PowerShell 7.0.6 LTS and PowerShell 7.1.3 or higher to use the Azure PowerShell or the az module on all platforms
You can check the version of your Powershell by running the following cmdlet in PowerShell,
If you have windows 10 or 11 you can upgrade your PowerShell to the latest version using the following cmdlet,
- AzureRM PowerShell module AzureRM PowerShell module also supports the previous version of PowerShell, but Microsoft will remove it on February .
What is Azure Powershell?
Azure PowerShell provides a set of command-lets that can be used to access and manage resources present in the Azure cloud directly from PowerShell.
A command-let(cmdlet) is a command that can be used only in PowerShell. Every cmdlet is named as a Verb-Noun pair. The verb denotes the action to be performed, and the Noun denotes the resource the action is performed.
- The Azure Cloud provides many services such as storage, Virtual machines, networking, development(DevOps), and much more.
- If we want to manage a resource or a service, we must reach the cloud dashboard using a browser.
- The Azure PowerShell provides a way to modify and see all resources in the Azure cloud using Powershell.
- The Azure PowerShell module comprises many modules related to Azure services. For example, it has the Az. Storage module for storage-related services, Az.Compute for services regarding virtual machines, etc.
- The Azure PowerShell cmdlets execute by making an API request to the Azure API.
PowerShell is not only supported in Windows. There is also an edition of PowerShell called the PowerShell Core, which is open source and has cross-platform support.
We need to install the Azure Az PowerShell module in our system to use the Azure Powershell. The following cmdlet can be used in Powershell to install the Az module.
The -AllowClobber parameter overwrites any module with the name Az if it is already in the system. The -Force parameter is used to install the module even though warnings appear.
After installing the module, we can use the following cmdlet to connect to your Azure cloud environment,
On running the above cmdlet, a window asks for credentials for your Azure cloud account. After connecting, you can view and modify or deploy new services using cmdlets provided by Azure Powershell. For example, the following cmdlet is used to list all resource groups in the Azure cloud.
We can view the output in different formats and download the result as a CSV file by using pipes and adding another command.
The | symbol denotes a pipe that takes the result of the first command and passes it to the second command and is commonly used in shell environments.
On executing an azure PowerShell cmdlet, it creates an Azure PowerShell object as output. These objects can also be called .NET objects. Azure PowerShell also provides cmdlets to query this output object to get only the details we want.
The advantages of using Azure PowerShell are,
- It is simple to use.
- We can create scripts with a series of commands that need to be performed and execute them to perform many tasks simultaneously.
For example, if we want to create 5 virtual machines, we can use the following script,
- We can sequence execute tasks and use pips to automate workflow.
- It is faster and more consistent as it is integrated with the systems Powershell.
Conclusion
- Azure PowerShell provides a set of cmdlets to manage services in the Azure cloud using Powershell.
- The Az PowerShell module is installed to use azure Powershell.
- We can use azure PowerShell in windows from windows 7 and it can also be used in mac and Linux OS using PowerShell core.
- The recommended version of Powershell to use azure PowerShell are PowerShell 7.0.6 LTS and PowerShell 7.1.3 or higher.