Use Azure PowerShell to manage your Azure Environment
Microsoft Azure offers several ways to manage the Azure workloads. These includes Azure Portal, SDK, Azure PowerShell etc. Azure PowerShell is the equivalent of Windows PowerShell, but you can execute commands against your Azure account. There are two ways you can use PowerShell commands in your Azure account
- Use Azure Cloud Shell
This is the browser version of Azure PowerShell. It gives bash experience for Linux users and PowerShell experience for windows users. You can try Azure Cloud Shell from the Link https://shell.azure.com/ - Azure PowerShell
Azure PowerShell can be installed on your computer and use.
This article focuses on how to install Azure PowerShell on windows 10 computer where PowerShell version 5 is installed.
Install Azure PowerShell
From your Windows 10 PC, open Windows PowerShell as administrator
I recommend you to check your PowerShell version and ensure you have version 5. To get the version of the Windows PowerShell, use the following command
Now you can Install Azure PowerShell Module with the following command
If NuGet provider is not installed, it will ask your consent to install it. The default value is Yes, so you can just use Enter key to install the NuGet Provider.
Since you are installing the AzureRM from web, it will ask your permission to install it. Be noted that the default value here is No, so you should enter Y and click Enter key.
The packages will be downloaded and installed. You will see the progress in the PowerShell command window.
Connect to your Azure Account
Once you installed Azure PowerShell, you need to use it with Windows PowerShell. Go to Windows PowerShell and import AzureRm module.
Import-Module AzureRM
When I first tried this command, I got the following error saying AzureRm.psm1 cannot be loaded because running scripts is disable on this system.
The reason for the error is that the execution policy of my PowerShell doesn’t allow remotely signed scripts to execute this. To resolve this error, you need to set the execution policy to allow remote signed. The corresponding Azure Command is given below
Set-ExecutionPolicy RemoteSigned
Once you set the execution policy to remotesigned, you can execute the command to Import AzureRM module.
Azure require you to login to your Azure account before you can execute any command against your Azure Account. Use the below command to connect to the Azure account.
Now the browser will be popped up with the sign in page. You enter your credentials and complete the authentication process.
Once authenticated, it will show your Azure Account details as below.
Now you are ready to execute commands against your Azure account. Let me check all the resource group in my account. For this I need to use the below command.
Get-AzureRmResourceGroup
Summary
Azure PowerShell is a great option for developers or system administrators to manage your Azure Environment by using standard Windows PowerShell. You can refer the Azure PowerShell commands from the below URL.
https://docs.microsoft.com/en-us/azure/virtual-machines/windows/ps-common-ref