Azure Classroomnotes 29/Jun/2022

ARM Templates Contd

Activity

  • Reference Architecture:
    Preview
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "resources": [
    {
        "type": "Microsoft.Network/virtualNetworks",
        "apiVersion": "2021-08-01",
        "name": "primaryvnet",
        "location": "southindia",
        "properties": {
            "addressSpace": {
                "addressPrefixes": [ "10.100.0.0/16" ]
            },
            "subnets": [
            {
                "name": "web",
                "properties": {
                    "addressPrefix": "10.100.0.0/24"
                }
            },
            {
                "name": "mgmt",
                "properties": {
                    "addressPrefix": "10.100.1.0/24"
                }
            },
            {
                "name": "app",
                "properties": {
                    "addressPrefix": "10.100.2.0/24"
                }
            },
            {
                "name": "db",
                "properties": {
                    "addressPrefix": "10.100.3.0/24"
                }
            }

            ]
        }
    },
    {
        "type": "Microsoft.Network/virtualNetworks",
        "apiVersion": "2021-08-01",
        "name": "secondaryvnet",
        "location": "centralindia",
        "properties": {
            "addressSpace": {
                "addressPrefixes": [ "10.101.0.0/16" ]
            },
            "subnets": [
            {
                "name": "web",
                "properties": {
                    "addressPrefix": "10.101.0.0/24"
                }
            },
            {
                "name": "mgmt",
                "properties": {
                    "addressPrefix": "10.101.1.0/24"
                }
            },
            {
                "name": "app",
                "properties": {
                    "addressPrefix": "10.101.2.0/24"
                }
            },
            {
                "name": "db",
                "properties": {
                    "addressPrefix": "10.101.3.0/24"
                }
            }

            ]
        }
    }
    ]
}
  • Lets try to use paramters to provide user inputs Refer Here and use them using functions Refer Here
  • Include the parameters
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "primaryregion": {
            "type": "string",
            "metadata": {
                "description": "This is the primary region"
            },
            "defaultValue": "southindia"
        },
        "secondaryregion": {
            "type": "string",
            "metadata": {
                "description": "This is the primary region"
            },
            "defaultValue": "centralindia"
        }

    },
    "resources": [
    {
        "type": "Microsoft.Network/virtualNetworks",
        "apiVersion": "2021-08-01",
        "name": "primaryvnet",
        "location": "[parameters('primaryregion')]",
        "properties": {
            "addressSpace": {
                "addressPrefixes": [ "10.100.0.0/16" ]
            },
            "subnets": [
            {
                "name": "web",
                "properties": {
                    "addressPrefix": "10.100.0.0/24"
                }
            },
            {
                "name": "mgmt",
                "properties": {
                    "addressPrefix": "10.100.1.0/24"
                }
            },
            {
                "name": "app",
                "properties": {
                    "addressPrefix": "10.100.2.0/24"
                }
            },
            {
                "name": "db",
                "properties": {
                    "addressPrefix": "10.100.3.0/24"
                }
            }

            ]
        }
    },
    {
        "type": "Microsoft.Network/virtualNetworks",
        "apiVersion": "2021-08-01",
        "name": "secondaryvnet",
        "location": "[parameters('secondaryregion')]",
        "properties": {
            "addressSpace": {
                "addressPrefixes": [ "10.101.0.0/16" ]
            },
            "subnets": [
            {
                "name": "web",
                "properties": {
                    "addressPrefix": "10.101.0.0/24"
                }
            },
            {
                "name": "mgmt",
                "properties": {
                    "addressPrefix": "10.101.1.0/24"
                }
            },
            {
                "name": "app",
                "properties": {
                    "addressPrefix": "10.101.2.0/24"
                }
            },
            {
                "name": "db",
                "properties": {
                    "addressPrefix": "10.101.3.0/24"
                }
            }

            ]
        }
    }
    ]
}

Preview
* Try to create parameters for address space of primary and secondary vnets and subnets

Leave a Reply

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

About continuous learner

devops & cloud enthusiastic learner