Azure Powershell

Azure PowerShell are command-line tools that enable you to create and manage Azure resources. It is a set of cmdlets for managing resources directly from PowerShell. Designed to make it easy to learn and get started with, but it provides powerful features for automation.

It is also a command line tool that uses the scripts or cmdlets to perform tasks such as creating and managing storage accounts or Virtual Machines that can easily be done using the preset commands.

Administrators can use the cmdlets to perform complex tasks like provisioning virtual machines or managing other hosted resources.

Module Creation:

The Az module is a wrapper module for its service related PowerShell modules, usually one module per Azure service such as Az.

The cmdlets in the Az PowerShell module make REST calls to the API. Breaking changes in the Az PowerShell module are limited to twice a year.

The Az PowerShell module contains cmdlets for performing both control plane and data plane operations in Azure. You use the control plane to manage resources in your subscription.

How Azure PowerShell Works?

It works by using mini scripts called cmdlets to perform powerful and common tasks in Microsoft Azure through an extension of Windows PowerShell. Without logging in, users can enter a single cmdlet from the command line to create a new virtual machine.

It is designed for managing and administering resources from the command line. Use it when you want to build automated tools that use the Resource Manager model. Try it out in your browser with Azure Cloud Shell, or install on your local machine.

It is a cross-platform shell and scripting language that allows people to manage tasks from the command line and automate thousands of activities.

How to install Azure Powershell?

Installing:
Step 1 – Login into Azure Management Portal.
Step 2 – Click ‘Downloads’.
Step 3 – Locate ‘command-line tools’ and ‘Windows’.
Step 4 – Click ‘Install’ listed under it to download the setup and install it.

Connecting to Your Subscription:
Step 1 – Locate Microsoft ‘Azure PowerShell’ in your programs.
Step 2 – Pin it to the taskbar. You can run it as ISE by pinning it to the taskbar in Windows.
Step 3 – If it doesn’t show the option of ‘Run ISE as Administrator’ it is in programs.
Step 4 – Right-click on ‘Microsoft Azure PowerShell’ and select ‘Run ISE as Administrator’.

Connect to Your Azure Account:
Using Active Directory:
Step 1 – Enter the following cmdlet in PowerShell and Add-AzureAccount.
Step 2 – Image will pop up and ask for credentials of your account.
Step 3 – Enter the credentials and sign in.
Step 4 – Now you are ready to perform tasks in Azure using Azure PowerShell.

Benefits of Azure Powershell:

  • Create a new virtual machine: Use the New-AzureRmVm cmdlet to create a new VM. You’ll have to create the Azure RM Config object first. Even so, this one can save hours of data entry in Azure Portal forms.
  • Configure a virtual machine: The Set-AzureRmVMCustomerScriptExtension cmdlet lets users run script files on their VM without the need to log in first.
  • Move content to an Azure Storage Blob from a local machine: The Set-AzureStorageBlobContent cmdlet lets you move content in a hassle-free way.
  • Create a new resource group for an Environment with the New-AzureRmResourceGroup cmdlet. This makes it easy to control and keep track of environments without a lot of extra work.

Do I need to learn PowerShell for Azure?

To get started with this tasks, you will have to first add your Azure account to PowerShell. You just have to perform this step once on your computer and every time or any time you can run Azure PowerShell, it will connect to the account automatically.