Loading....
Lab
Cloud Vendor Microsoft Azure
Proficiency Level Cloud Enthusiast
Tags AutomationAzure ARMAzure PowerShellAzure StorageCI/CDPowerShell

Summary

In this lab, you will create an Azure Storage Account using Azure Resource Manager (ARM) and Azure PowerShell. You will use the command line to run PowerShell cmdlets that will sign you in to Azure and deploy the ARM template.

Each exercise below builds upon the previous one. You should start each new exercise from the last step of the previous exercise unless it is explicitly written otherwise.

Learning Objectives

After completion of this lab, you will be able to:

Prerequisites

To complete this lab, you will need the following:

  • Reliable internet connection
  • A work, school or personal Microsoft Account used to access Microsoft Azure Management Portal
  • A subscription for Microsoft Azure
  • PowerShell Core installed on your laptop (Windows, Mac or Linux)
  • Azure PowerShell cmdlets installed on your laptop

Exercise #1: Sign In To Azure Using Azure PowerShell

In this exercise, you will sign in to Azure using Azure PowerShell and select a subscription to work with.

Steps

  1. Start a PowerShell command window on your laptop
  2. Type the following command at the prompt
    Connect-AzAccount
  3. Follow the printed instructions to sign in to Azure using your browser
  4. Once you are signed in, the default subscription for your account will be printed
  5.  Milestone step:  At this point, you have learned how to sign in to Azure from a PowerShell command window
  6. Type the following command at the prompt
    Get-AzSubscription
  7. That will print a list of all subscriptions you have access to with your account
  8.  Milestone step:  At this point, you have learned how to list all Azure subscriptions you have access to from a PowerShell command window
  9. Copy the Id of the subscription you want to use for the deployment
  10. Type the following command at the prompt
    Select-AzSubscription -SubscriptionId [subscription_to_use]
  11. That will print the details of the subscription you will use for the deployment
  12.  Milestone step:  At this point, you have learned how to select an Azure subscription to deploy resources from a PowerShell command window

Exercise #2: Deploy an ARM Template Using Azure PowerShell

In this exercise, you will create a new resource group and deploy an ARM template that creates a Storage Account using Azure PowerShell.

Steps

  1. Open a code editor and paste the following code in it
    {
        "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
            "storageAccount_name": {
                "defaultValue": "[first_name_and_initials]autlab01str",
                "type": "String"
            }
        },
        "variables": {},
        "resources": [
            {
                "type": "Microsoft.Storage/storageAccounts",
                "apiVersion": "2019-04-01",
                "name": "[parameters('storageAccount_name')]",
                "location": "westus2",
                "tags": {
                    "Application": "Training",
                    "Owner": "[owner_name]",
                    "OwnerEmail": "[owner_email]",
                    "Purpose": "Education",
                    "Version": "1.0"
                },
                "sku": {
                    "name": "Standard_LRS",
                    "tier": "Standard"
                },
                "kind": "StorageV2",
                "properties": {
                    "networkAcls": {
                        "bypass": "AzureServices",
                        "virtualNetworkRules": [],
                        "ipRules": [],
                        "defaultAction": "Allow"
                    },
                    "supportsHttpsTrafficOnly": true,
                    "encryption": {
                        "services": {
                            "file": {
                                "enabled": true
                            },
                            "blob": {
                                "enabled": true
                            }
                        },
                        "keySource": "Microsoft.Storage"
                    },
                    "accessTier": "Hot"
                }
            },
            {
                "type": "Microsoft.Storage/storageAccounts/blobServices",
                "apiVersion": "2019-04-01",
                "name": "[concat(parameters('storageAccount_name'), '/default')]",
                "dependsOn": [
                    "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccount_name'))]"
                ],
                "properties": {
                    "cors": {
                        "corsRules": []
                    },
                    "deleteRetentionPolicy": {
                        "enabled": false
                    }
                }
            }
        ]
    }
  2. Make the following modifications in the above code
    Line 6 → Replace  [first_name_and_initials] with your first name and initials
    Line 19 → Replace  [owner_name] with your name
    Line 20 → Replace  [owner_email] with your email
  3. Save the file in your home folder with the following name
    template.json
  4. In your PowerShell command window, change the path to your home folder
  5. Type the following command in your PowerShell command window
    New-AzResourceGroup -ResourceGroupName '[first_name_and_initials]automationlab01-rg' -Location 'westus2'
  6.  Milestone step:  At this point, you have learned how to create a new Resource Group in Azure using the Azure PowerShell cmdlets
  7. Type the following command in your PowerShell command window
    New-AzResourceGroupDeployment -ResourceGroupName '[first_name_and_initials]automationlab01-rg' -TemplateFile 'template.json'
  8. Once the deployment is complete, you will see a summary of the deployed resources printed in the command window
  9.  Milestone step:  At this point, you have learned how to create a new Resource Group deployment in Azure using the Azure PowerShell cmdlets and ARM templates
  10. Verify that the new resource group and storage account are available in Azure Management Portal

Last Update: November 5, 2019  

November 5, 2019   171   Toddy Mladenov    Cloud Management    
Total 0 Votes:
0

Tell us how can we improve this post?

+ = Verify Human or Spambot ?

Back To Top