Configuring PowerShell For Azure

What is PowerShell?

PowerShell is an object-oriented programming language and interactive command line shell for Microsoft Windows. It is basically designed to automate the tasks.

PowerShell provides the following options for automating the tasks.

  • By instantiating .Net classes.
  • Using Cmdlets which are small .Net classes that appear as system commands.
  • Using scripts as .ps1 file, which are combinations of cmdlets and associated logic.

Azure provides the different PowerShell modules to manage the Azure services and solutions deployed on Azure. Given below are the steps to configure the Windows PowerShell for using Azure and we call it Azure PowerShell.

What is Azure PowerShell?

Azure PowerShell is a collection of PowerShell modules provided by Azure to manage Azure services using Cmdlets in Windows PowerShell.

Below steps show how to configure PowerShell for Azure.

  1. We need to install the Azure PowerShell. We can achieve this by using Web Platform Installer (WebPI) or PowerShell Gallery. In this article, we will see the process by using Web Platform Installer (WebPI).

    • Installing using Web Platform Installer (WebPI): For this option, you need Web Platform Installer application. If it’s not installed on your system, install it from Web Platform Installer , and follow the below steps.

      1. Run Microsoft Web Platform Installer

        You can run this application from All Programs or if you have created a desktop shortcut, then run it from there. Also, you can search in Search programs and files box, as shown in the image.

        Microsoft Web Platform Installer

        As the application starts, you will see the Microsoft Azure PowerShell in Spotlight section. If it’s not there, then it can be searched from search box at the top right side.

      2. Select the Microsoft Azure PowerShell and click on Add button. Then, click the install button, as shown in below image.

        Microsoft Azure PowerShell

      3. The above action opens up a new window for Prerequisites details, if required. In the license acceptance, click on I Accept, as shown in below image.

        Prerequisites

        After clicking on I Accept button, Web Platform Installer will be downloaded. Install the Azure PowerShell and do the required configuration, if needed, behind the scene. The Downloading and Installation progress is shown in the below image.

        Prerequisites

        After successful installation, a successful installation message is displayed. Click on Finish button and close the Web Platform Installer.

        Prerequisites

    Now, the Azure PowerShell is installed successfully. We can start using it and can run the cmdlets from the standard Windows PowerShell console, or from PowerShell Integrated Scripting Environment (ISE). I am using PowerShell Integrated Scripting Environment (ISE) as it provides some intelligence and easy editing options.

  2. Start PowerShell Integrated Scripting Environment (ISE) as administrator, as shown in the following image.

    administrator

    The above action opens the Windows PowerShell ISE in administrator mode, as shown in the below image.

    Windows PowerShell ISE

    As seen on the right hand side, there is a list of all the modules in Modules dropdown and filtered cmdlets list below it, available to work with. You can filter modules as well. By Default a PowerShell file is created and there is a blue PowerShell command window where we will work with Azure cmdlets.

    We can verify the installed Modules by using the Cmdlets Get-Module –ListAvailable, as shown in the image.

    ListAvailable

    As shown in the above image, there are locations where the module's installed and the list of modules and cmdlets commands.

  3. Now, we will connect to Azure subscription to work with Azure services, as shown in the below image, using Login-AzureRmAccount, as we are managing our Azure services using resource manager modules. The other way of working with Azure services using PowerShell is service management. We refer to it as classic deployment in Azure portal.

    azure

    Enter the login credentials of Azure subscription and hit Enter. After successful authentication, it displays your subscription details, as shown in below image.

    credentials

    • We can view our current Azure PowerShell session context, in which we have to work using Get-AzureRmContext cmdlets, as shown in below image.

      Get-AzureRmContext

    • We can view all our subscriptions associated with logged in credentials, as shown in the below image.

      credentials

    • I have already set the Azure context to work with in current PowerShell session. If we have to work with different subscriptions, then we have to set the current Azure PowerShell session with that subscription.

      subscription

Our PowerShell is now ready to work with Azure and we can use it to create, delete, view, and change, Azure resources as we do from Azure portal.


Similar Articles