Resource Manager Cmdlets in Azure PowerShell 1.0

This is a cross-posting of Resource Manager Cmdlets in Azure PowerShell 1.0 at Kloud.

Azure recently launched the 1.0 version of PowerShell cmdlets. The changes are huge, including new Azure Resource Manager (ARM), which resulted in deprecating Azure-SwitchMode between ASM and ARM. In this post, we only have a brief look at how new PowerShell cmdlets for ARM have been introduced, especially for managing resource groups and templates.

Installation

In order to get the newest Azure PowerShell, using MS Web Platform Installer is the quickest and easiest way.

Note: At the moment of writing, the released date of Azure PowerShell is Nov. 9th, 2015.

Of course, there are other ways to install the latest version of Azure PowerShell, but this is beyond the scope of this post.

New Set of Cmdlets

Now, the new version of Azure PowerShell has been installed. Run PowerShell ISE with an Administrator privilege. As always, run Update-Help to get the all help files up-to-date. Then try the following command:

https://gist.github.com/justinyoo/e9bee00c2eca5368e20c

If you can’t see anything, don’t worry. You can restart ISE or even restart your PC.

Alternatively, you can check those cmdlets through ISE like:

Can you find any differences comparing to the previous version of cmdlets? All cmdlets are named as patterns of [action]-AzureRm[noun]. For example, in order to get the list of resource groups, you can run Get-AzureRmResourceGroup. The result will look like:

https://gist.github.com/justinyoo/70a1b4da8a2ff02befa3

Now, let’s try to setup a simple web application infrastructure. For the web application, at least one website and database is required. In addition to them, for telemetry purpose, ApplicationInsights might be necessary.

Create a Resource Group

For those infrastructure, we need a resource group. Try the following cmdlets in that order:

https://gist.github.com/justinyoo/71a9fb54da840e1e66b0

Can you find out the differences from the old cmdlets?






















Old Cmdlets New Cmdlets
Get-AzureAccount Login-AzureRmAccount
Get-AzureSubscription Get-AzureRmSubscription
Select-AzureSubscription Select-AzureRmSubscription

As stated above, all cmdlets now have names of AzureRm instead of Azure. Once you complete choosing your subscription, if you have more than one subscription, it’s time to create a resource group for those infrastructure items. It might be worth having a look naming guidelines for Azure resources. Let’s try it.














Old Cmdlets New Cmdlets
New-AzureResourceGroup New-AzureRmResourceGroup

Therefore, enter the following to create a resource group:

https://gist.github.com/justinyoo/3b18cf63a68f748ceb10

The resource group is now named as ase-dev-rg-sample and created in the Australia Southeast (Melbourne) region. Let’s move onto the next step, setting up all resources using a template.

Setup Resources with Azure Resource Template

Fortunately, there is a template for our purpose on GitHub repository: https://github.com/Azure/azure-quickstart-templates/tree/master/201-web-app-sql-database.














Old Cmdlets New Cmdlets
New-AzureResourceGroupDeployment New-AzureRmResourceGroupDeployment

Use the new cmdlet and add all resources into the group:

https://gist.github.com/justinyoo/988133a974a5a3000a52

As you can see, we set the template file directly from GitHub and left parameter source. Therefore, it will ask to type necessary parameters:

https://gist.github.com/justinyoo/b2137fd8989eba28fbc3

Once everything is entered, as I put -Verbose parameter, all setup details will be displayed as well as result:

https://gist.github.com/justinyoo/8fb9a0643d54e9c75e09

Check out the Azure Portal whether all defined resources have been deployed or not.

Everything has been smoothly deployed.

We have so far had a quick look of ARM with resource group management. There are more cmdlets in Azure PowerShell to control individual resources more precisely. I’m not going to deep dive too much here, but it’s much worth trying other cmdlets for your infrastructure setup purpose. This is even more powerful than before.