This blog post explains how to use Azure PowerShell with Azure Resource Manager Templates to deploy the desired resources to Azure. To better understand this article, please read part-I of the series that explains Azure Resource Manager, Azure Resource manager Template, basic structure and syntax of the ARM template and sample template for creating a storage account in Microsoft Azure.
Now let’s see how we can deploy the template to Azure subscription using PowerShell cmdlets
Prerequisites for deploying ARM template:
- Azure Subscription
- Azure PowerShell a command line interface for managing and administering Azure resources and for building automation scripts that work against the Azure Resource Manager. If you have not yet installed, download, download it (https://azure.microsoft.com/en-us/downloads/) and install it .
- Knowledge of working with PowerShell scripts and cmdlets. If you are not familiar please visit the link to understand basics of Azure PowerShell
Deploy the resource using template
- Launch Azure Powershell. Login in using your Azure subscription credentials. Type the below commands.
C:\windows\system32> Set-AzureRmContext -SubscriptionID <<your subscriptionid>> The Set-AzureRmContext cmdlet sets authentication information for cmdlets that is executed in the current session. The context includes tenant, subscription, and environment information. The above command sets the context to use the specified subscription.C:\windows\system32> New-AzureRmResourceGroup -Name armgroup -Location "EastAsia”
- C:\windows\system32> New-AzureRmResourceGroup -Name arm group -Location "Eastasia” The New-AzureRmResourceGroup cmdlet creates an Azure resource group. It creates an empty resource group with no resources. The resources can be added to this group later by using the New-AzureRmResource or New-AzureRmResourceGroupDeployment cmdlets to add resources and deployments to this resource group as illustrated in the following cmdlet.
- PS C:\windows\system32> New-AzureRmResourceGroupDeployment -Name armgroup -ResourceGroupName arm test group -TemplateFile d:\storagearm.json -storage SKU "Standard_GRS"
Output as shown below:
Now visit your personal dashboard on the Azure portal and browse the resources to check whether the storage account has been created. (Sample snapshot as shown below.)
This brings us to the end of this article. In the part-III of the same series you will learn how to deploy ARM template using Azure Portal.
For more information on please visit the following MSDN links