Azure Classroomnotes 25/Mar/2023

Infrastructure as Code (IaC)

  • In this approach we define infra as code i.e. infra need for applications will be declared.
  • We specify the desired state.
  • For IaC, Azure has two approaches supported natively
    • ARM Templates
    • Azure Bicep

Azure Resource Manager Templates (ARM Templates)

  • Here we define our infrastructure in JSON Format.
  • ARM Templates can be applied at (Scope)
    • Resource Group level
    • Subscription Level
    • Management Group level
  • ARM Template syntax: Refer Here for arm template syntax
  • Template skeleton
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "",
  "apiProfile": "",
  "parameters": {  },
  "variables": {  },
  "functions": [  ],
  "resources": [  ],
  "outputs": {  }
}
  • Required fields are $shema, content version and resources
  • contentVersion: This is version of arm template which we are authoring. Recommended versioning major.minor.patch.id i.e. 1.0.0.0
  • $Schema:
    • subscription level: https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#
    • resource group level: https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#
    • management group level: https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#
    • tenant level: https://schema.management.azure.com/schemas/2019-08-01/tenantDeploymentTemplate.json#
  • resources: This represents resources which we want to create using ARM Templates.

Intersting facts about ARM

  • Try creating vm using Azure portal and observe deployments

  • Azure creates arm template for the vm and all the related resources.

Activity 1: ARM Template to create Storage Account

  • Manual Steps:
    • Ensure you have a resource group
    • Refer Here for steps
  • ARM Ways of Working:
    • Deployment: Resource Group level
    • inputs:
      • storage account name
      • resource group name
    • Desired state: storage account
  • Setup:
    • Lets install ARM Tools extension into visual studio code Refer Here
  • For resource Refer Here
  • We have authored a template which looks as shown below
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "resources": [
        {
            "name": "qtstorageaccfromarm",
            "type": "Microsoft.Storage/storageAccounts",
            "apiVersion": "2022-09-01",
            "location": "East US",
            "sku": {
                "name": "Standard_GRS"
            },
            "kind": "StorageV2",
            "properties": {
                "accessTier": "Hot",
                "allowBlobPublicAccess": true
            }
        }
    ]
}
  • Now create a resource group armlearning and try deploying the template






  • Refer Here for changes

Activity2: ARM Template to create Vnet

  • Refer Here for azure docs to create a vnet
  • inputs:
    • vnet name
    • region
    • address space
    • subnet
      • subnet address space
  • create the deployment using the json. Refer Here for the changeset.
  • Exercise: Wirte ARM Template for the below case.
Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%