Azure ARM Classroom Series – 27/Sep/2019

Architecture We would like to realize using ARM Tempaltes

Preview

Things we acheived so far.

  • Only Virtual Network
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion" : "1.0.0.0",
    "resources": [
        {
            "name": "fromarm",
            "type": "Microsoft.Network/virtualNetworks",
            "apiVersion": "2019-04-01",
            "location": "Central US",
            "properties": {
                "addressSpace": {
                    "addressPrefixes":["192.168.0.0/16"]
                }

            }
        }
    ]
}
  • Identify Resource Dependenices. If Resource B require Resource A to be created, then Resource B has dependency on Resource A. eg Subnet has dependency on Virtual Network

  • Lets add subnet appgateway as child resource

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion" : "1.0.0.0",
    "resources": [
        {
            "name": "fromarm",
            "type": "Microsoft.Network/virtualNetworks",
            "apiVersion": "2019-04-01",
            "location": "Central US",
            "properties": {
                "addressSpace": {
                    "addressPrefixes":["192.168.0.0/16"]
                }

            },
            "resources": [
                {
                    "name": "fromarm/appgateway",
                    "type": "Microsoft.Network/virtualNetworks/subnets",
                    "apiVersion": "2019-04-01",
                    "dependsOn":["fromarm"],
                    "properties": {
                        "addressPrefix": "192.168.0.0/24"
                    }
                }
            ]   
        }
    ]
}
  • Lets add the other 5 subnets
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion" : "1.0.0.0",
    "resources": [
        {
            "name": "fromarm",
            "type": "Microsoft.Network/virtualNetworks",
            "apiVersion": "2019-04-01",
            "location": "Central US",
            "properties": {
                "addressSpace": {
                    "addressPrefixes":["192.168.0.0/16"]
                }

            },
            "resources": [
                {
                    "name": "fromarm/appgateway",
                    "type": "Microsoft.Network/virtualNetworks/subnets",
                    "apiVersion": "2019-04-01",
                    "dependsOn":["fromarm"],
                    "properties": {
                        "addressPrefix": "192.168.0.0/24"
                    }
                },
                {
                    "name": "fromarm/management",
                    "type": "Microsoft.Network/virtualNetworks/subnets",
                    "apiVersion": "2019-04-01",
                    "dependsOn":["fromarm"],
                    "properties": {
                        "addressPrefix": "192.168.1.0/24"
                    }
                },
                {
                    "name": "fromarm/web",
                    "type": "Microsoft.Network/virtualNetworks/subnets",
                    "apiVersion": "2019-04-01",
                    "dependsOn":["fromarm"],
                    "properties": {
                        "addressPrefix": "192.168.2.0/24"
                    }
                },
                {
                    "name": "fromarm/business",
                    "type": "Microsoft.Network/virtualNetworks/subnets",
                    "apiVersion": "2019-04-01",
                    "dependsOn":["fromarm"],
                    "properties": {
                        "addressPrefix": "192.168.3.0/24"
                    }
                },
                {
                    "name": "fromarm/data",
                    "type": "Microsoft.Network/virtualNetworks/subnets",
                    "apiVersion": "2019-04-01",
                    "dependsOn":["fromarm"],
                    "properties": {
                        "addressPrefix": "192.168.4.0/24"
                    }
                },
                {
                    "name": "fromarm/adsubnet",
                    "type": "Microsoft.Network/virtualNetworks/subnets",
                    "apiVersion": "2019-04-01",
                    "dependsOn":["fromarm"],
                    "properties": {
                        "addressPrefix": "192.168.5.0/24"
                    }
                }
            ]   
        }
    ]
}
  • Try deployment & check the results

Limitations of our ARM Template so far

  • This template has hardcoding for
    • Vnet Names
    • Subnet Name
    • Address Spaces/CIDR Ranges
  • This template is very specific

Lets sort out on problems

Parameters:

  • Refer Here for syntax

  • Lets do a simple test add a dummy paramter called as test parameter to the existing and see the behavior

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion" : "1.0.0.0",
    "parameters": {
        "testparamter":{
            "type": "string"
        }
    },
    "resources": [
        {
            "name": "fromarm",
            "type": "Microsoft.Network/virtualNetworks",
            "apiVersion": "2019-04-01",
            "location": "Central US",
            "properties": {
                "addressSpace": {
                    "addressPrefixes":["192.168.0.0/16"]
                }

            },
            "resources": [
                {
                    "name": "fromarm/appgateway",
                    "type": "Microsoft.Network/virtualNetworks/subnets",
                    "apiVersion": "2019-04-01",
                    "dependsOn":["fromarm"],
                    "properties": {
                        "addressPrefix": "192.168.0.0/24"
                    }
                },
                {
                    "name": "fromarm/management",
                    "type": "Microsoft.Network/virtualNetworks/subnets",
                    "apiVersion": "2019-04-01",
                    "dependsOn":["fromarm"],
                    "properties": {
                        "addressPrefix": "192.168.1.0/24"
                    }
                },
                {
                    "name": "fromarm/web",
                    "type": "Microsoft.Network/virtualNetworks/subnets",
                    "apiVersion": "2019-04-01",
                    "dependsOn":["fromarm"],
                    "properties": {
                        "addressPrefix": "192.168.2.0/24"
                    }
                },
                {
                    "name": "fromarm/business",
                    "type": "Microsoft.Network/virtualNetworks/subnets",
                    "apiVersion": "2019-04-01",
                    "dependsOn":["fromarm"],
                    "properties": {
                        "addressPrefix": "192.168.3.0/24"
                    }
                },
                {
                    "name": "fromarm/data",
                    "type": "Microsoft.Network/virtualNetworks/subnets",
                    "apiVersion": "2019-04-01",
                    "dependsOn":["fromarm"],
                    "properties": {
                        "addressPrefix": "192.168.4.0/24"
                    }
                },
                {
                    "name": "fromarm/adsubnet",
                    "type": "Microsoft.Network/virtualNetworks/subnets",
                    "apiVersion": "2019-04-01",
                    "dependsOn":["fromarm"],
                    "properties": {
                        "addressPrefix": "192.168.5.0/24"
                    }
                }
            ]   
        }
    ]
}
  • Now try the deployment using portal and you should see the new input section Preview

Refer Blog item

Leave a Reply

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

About continuous learner

devops & cloud enthusiastic learner