Microsoft Azure Storage setup via Azure ARM Template – A step by step configuration

steps 15-21 for storage account

This post is in continuation to the previous post on Azure Storage Services where we learned how to deploy a storage account from the Azure portal. Now, we will explore the Azure Storage ARM Template deployment.

Before we start with that, a few things to note:

  1. It is advised to use Microsoft Visual Studio with the Azure Libraries to write the code for the deployment. (Microsoft Visual Studio is a very powerful tool that will provide intellisense for azure commands and the template can be deployed from Visual Studio itself).
  2. Azure Resource Manager Templates are written in JSON scripts, so it will be a plus point to have some basic knowledge in JSON scripting.
  3. The ARM template comprises three main files.
    1. JSON- The main template file where the resource is defined.
    2. parameters.json- The parameters template file that contains the parameters as defined in the main template file.
    3. Deploy-AzureResourceGroup.ps1- The PowerShell script that checks the deployment (validation) and finally deploys the ARM template to Azure.
  4. If you are not using the Microsoft Visual Studio, you can deploy the ARM script using a simple PowerShell command (listed at the bottom of the page).

Now let’s get started with the JSON script for deploying an Azure Storage ARM Template with Visual Studio.

Steps 1-5: Fig.1

  1.  Open Visual Studio and click on File-New-NewProject. If you have the Azure Libraries installed properly, you will see the Cloud options as shown in the Fig.1.
  2.  Click on the Cloud option from the menu.
  3. Select the Azure Resource Group project type.
  4. Name your project (Visual Studio takes this name from default for the new resource group. However, it is not mandatory to use the same for the new resource group name.)
  5. Step 5: Click on OK and then the Azure Sample Repositories options page will appear.
ARM template to deploy storage account
Fig. 1. Steps 1-5 to deploy Storage Account ARM Template

Steps 6-8: Fig.2

  1. In the search box type storage to select a sample template for deploying a storage account.
  2. Select the 101-create-storage-account option from the list (GIT repository
  3. Click on okay and go to the next page. Here the azuredeploy.json, azuredeploy.parameters.json and deploy-AzureResourceGroup.ps1 files can be seen in the solution explorer.
ARM template to deploy storage account
Fig. 2. Steps 6-8 to deploy Storage Account ARM Template

Steps 9-14: Fig.3

  1.  After the template loads from Step 8, click on the azuredeploy.json file in the solution explorer (right-hand side). You will now see a JSON template for deploying a storage account in the Standard Tier with the LRS replication type. On the left-hand side, you will see a menu with 4 options. These are the integral parts of the deployment template.
  2. Parameters: Here you define all the parameters that you will be calling in the resources. These parameters are user-defined inputs for the respective values of the resources to be deployed.
  3. Variables: Here you define any variables that you will repeatedly use in the resource part.
  4. Resources: The resources that will be deployed are defined here. The integral parts over here are the name, type, apiVersion, location, properties etc (depends and varies from resource to resource).
  5. Outputs: This field can be used to identify the names/ schema of any resources that have been deployed from the ARM template.
  6. Now that we have a brief understanding of the JSON script, let’s go ahead and check the deployment. Before deploying the script, it is advised to first validate it. Right-click on the name of the solution and click on validate.
Fig. 3 Steps to deploy Storage Account ARM Template
Fig. 3. Steps 9-14 to deploy Storage Account ARM Template

 Steps 15-21: Fig.4

  1. After clicking the validate button in Step 14, a new window will appear as shown in the figure.
  2. Here you will be prompted to choose/ sign in to your Microsoft account that is linked to Azure.
  3. In this drop-down, you will have to choose the subscription in which you want to create this storage account.
  4. In this drop-down either choose an existing resource group or create a new one. IN case you chose to create a new one,
    1.  The subscription chosen appears here.
    2.  Type the resource group here and click on create.
  5. Select the main template file to be deployed (in case you are working on nested templates)
  6. Select the main parameters to file for the deployment and click on validate.
steps 15-21 for storage account
Fig. 4. Steps 15-21 to deploy Storage Account ARM Template

Steps 22-26: Fig.5

  1. Upon clicking the validate button from the previous button, an output screen will appear where you can see the account, subscription details.
  2.  Check the location, resource group name. The resource ID is generated in the specified schema.
  3. If everything is correct, the template is valid.
  4.  Now right-click the project name in the solution explorer and click on the deploy button. A new window pops up as shown in the figure.
  5. You will see the new resource group has been created here. Now if you wish to change any parameters, do so by clicking the Edit Parameters button.
  6. Click on Deploy and wait for the output screen to appear.
steps 22-26 for storage account
Fig. 5. Steps 22-26 to deploy Storage Account ARM Template

Steps 27-29: Fig.6

  1. The deployment of the script begins, and you can see the details of the account and validation etc. on the output screen.
  2. You can see the deployment has begun and based on the resource type, internet connection and such variables, the deployment proceeds.
  3. You can see the parameters that were declared at the time of deployment. In our scenario, we put the storage account type in the parameters field.
  4.  The deployment is finally successful and you can see that the resource group and the storage account has successfully been deployed.
steps 27-29 for storage account
Fig. 5. Steps 27-29 to deploy Storage Account ARM Template

(Optional) Step 30: Deploying the ARM template from PowerShell.

  1. First login and connect to your account from PowerShell.
  2. Use the following command to create a resource group:
    1. New-AzureRmResourceGroup -Name testrgstrg -Location “Central US”
  3. Use the following command to deploy the template:
    1. New-AzureRmResourceGroupDeployment -Name DeploymentTest -ResourceGroupName ExampleResourceGroup -TemplateFile c:\azuredeploy.json -TemplateParameterFile c:\azuredeploy.parameters.json

In the next post, we will see how to create a storage account from PowerShell using the RM Library.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

code