Azure – Using Powershell

Introduction

 In this article, I am going to show how to set up resources to work with Azure using power shell. We will learn basic power shell commands which are required to work with Azure. This article can be used by beginners, intermediates, and professionals. 

Prerequisite

  • Azure subscription
  • Windows Power shell version 5.1.1

First, we will check which version of Powershell has been installed in your machine using the below command CommandHost

 If you don’t have version 5.1.1 in your machine, it means you don’t have Windows Management Framework 5.1 installed in your machine. You can download and install the correct version from the below URL. Please select the correct version as per the operating system from the below URL. https://www.microsoft.com/en-us/download/details.aspx?id=54616 Also, we should have a NuGet installed on the machine. The below command can be used to install Nuget if not installed CommandInstall-PackageProvider -Name Nuget -RequiredVersion 2.8.5.201 – force

Tools

 We can connect and use Azure in various ways using various tools. To work with Microsoft Azure it’s better to know all these tools. Few of these tools are,

  1. Azure Portal
  2. Windows Power shell
  3. Azure Command Line Interface (CLI)
  4. Azure cloud shell – This allowed you to use both Bash and power shell from inside Azure portal.

Here I am going to show, how to connect and use Azure with Window Power shell commands. 

How to connect Azure using Powershell?

 Below are the steps we need  to follow to work with a power shell command,

  • Open Window Power shell command line as administrator.
  • First, we need to set execution policies so we can go and install remotely signed packages.

CommandSet-ExecutionPolicy RemoteSigned

  • Once the above settings will be done, we will install all Azure modules required for the current users using the below command.

CommandInstall-Module -Name Az -AllowClobber -Scope CurrentUser

  • Once Azure modules are installed, we need to import Az to work with Azure command. Please note that ‘Az’ is used for Azure. 

CommandImport-Module Az verbose 

  • Once modules are imported, we will try to connect the Azure account. Execute the below command.

CommandConnect-AzAccount

 Once you’ve logged in with credentials you will see the below image with subscription details like Account, SunscriptionName, TenantId, and Environment. 

 Let’s try to get all resources available with our account. CommandGet-AzResourceGroup

 Now we will create a new resource group and then check again using commands. CommandNew-AzResourceGroup -Name RG01 -Location “South Central US” 

 Let’s try to get all resource groups again to check if the new resource group is created or not. CommandGet-AzResourceGroup

 You can see in the above image that newly created resource groups have been created. We can execute and achieve any thing using power shell commands. It’s not possible to cover all commands in a single article

Lascia un commento