Azure User Group Nepal
Learn and understand the cloud technology using Microsoft Azure platform to adopt it
Managing Azure Subscription using Azure PowerShell
July 16, 2017
What is Azure PowerShell
Azure PowerShell is an extension of the Windows PowerShell to provide cmdlets for the management of Azure resources and cloud services. It is more manageable than the portal, for instance, if we want to stop all VMs in one go, we cannot do that from portal we need to stop one by one but from Azure PowerShell, we can stop all the VMs in one go.
Why use Azure PowerShell to Manage Azure Resources
- Provision and manage environment quickly.
- Some features are only available to PowerShell.
- Perform multiple operations simultaneously.
- DSC(Desired State Configuration) and Automation.
we will discuss DSC(Desired State Configuration) and automation in the upcoming post.
Install Azure PowerShell
- .Net framework 4.5 or higher: we can check the .net version by following PowerShell command
If .net framework is not installed then we can install using below PowerShell command.
- PowerShell version should be 4 or higher, we can check PowerShell version by the command.
Microsoft Web Platform Installer
Download Microsoft Web Platform Installer from here and install on the management computer. Current Web Platform Installer version is 5.0, click on Free Download button.
Run the setup and click on Add button for Microsoft Azure PowerShell.
Click on Install button.
Accept the license agreement.
The installation has started.
Azure PowerShell has installed successfully.
Verify Azure PowerShell has installed
To verify that Azure PowerShell has installed in the management computer by below command.
Get-Module -listavailable *azure*
We can see the Azure PowerShell module has installed.
Importing Azure Publish Settings File
Get PublishSettings File
To make a secure connection between management computer and Azure Subscription we need to import publish settings file by below command.
After hitting the Enter key, it will prompt you to log in to Azure Subscription. Login with your valid azure account.
After providing the subscription credential, file will be downloaded.
Import the PublishSettings file
Copy the publish settings file into C drive of the local computer.
Import the certificate using below PowerShell command. If we have more then one subscription then we need to repeat the step for each subscription. we don’t need local account privilege to run the command.
Import-AzurePublishSettingsFile -PublishSettingsFile ‘C:\Visual Studio Enterprise-7-16-2017-credentials.publishsettings’
Now, management computer is securely connected to azure subscription. Afterward we can run the azure command in powershell console without any authentication as it is already authenticated for the computers.
This certificate will only allow to access ASM(Azure Service Manager) commands but not to ARM(Azure Resource Manager) commands.
Note: who has not known to the difference between ASM and ARM command, ARM command contains Rm
ASM command: Get-AzureVm, ASR Command: Get-AzureRmVm
We can see on above image Get-AzureVm command is working but Get-AzureRmVm command is not working, to access the ARM command we need to log in with Login-AzureRmAccount.
Access Azure Resource Manager (ARM)
To access resources from ARM run the below command and provide subscription credentials.
Now, we have successfully signed in to ARM and we can access the resources as shown below.
To provision and manage VMs using Azure PowerShell visit this link.
Total visits : 38