Skip to content

Instantly share code, notes, and snippets.

@chgeuer
Created October 14, 2019 08:08
Show Gist options
  • Save chgeuer/aa248ca56191df76fae79be324e33734 to your computer and use it in GitHub Desktop.
Save chgeuer/aa248ca56191df76fae79be324e33734 to your computer and use it in GitHub Desktop.

passing a single object

main.json

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "tenantName": { "type": "string" },
        "deployRegServer": { "type": "string" },
        "regServerInstanceCount": { "type": "int" },
        "deployPortalServer": { "type": "string", },
		"portalServerInstanceCount": { "type": "int" },
		...
    },
    "variables": {
        "tierName": {
            "regserver": "regserver",
            "database": "database",
            "hostserver": "hostserver",
            "webportal": "webportal",
            "jumphost": "jumphost"
        },
        "apiVersions": {
            "storageAccounts": "2015-06-15",
            "networkSecurityGroups": "2015-06-15",
            "loadBalancers": "2016-03-30",
            "virtualNetworks": "2015-06-15",
            "publicIPAddresses": "2015-06-15",
            "networkInterfaces": "2015-06-15",
            "virtualMachines": "2015-06-15",
            "virtualMachineScaleSets": "2015-06-15",
            "deployments": "2015-01-01"
        },
        "commonSettings": {
            "constants": {
                "apiVersions": {
                    "storageAccounts": "2015-06-15",
                    "networkSecurityGroups": "2015-06-15",
                    "deployments": "2015-01-01"
                }
            },
            "tenantName": "[parameters('tenantName')]",
            "repositoryUrl": "[parameters('repositoryUrl')]",
            "longtermResourceGroupName": "[parameters('longtermResourceGroupName')]",
            "hostServerInstanceCount": "[parameters('hostServerInstanceCount')]",
            "deployRegServer": "[parameters('deployRegServer')]",
            "regServerInstanceCount": "[parameters('regServerInstanceCount')]",
            "deployPortalServer": "[parameters('deployPortalServer')]",
            "portalServerInstanceCount": "[parameters('portalServerInstanceCount')]",
            "databaseNodeInstanceCount": "[parameters('databaseNodeInstanceCount')]",
            "adminUsername": "[parameters('adminUsername')]",
            "adminSecureShellKey": "[parameters('adminSecureShellKey')]"
        }
    },
    "resources": [
        {
            "name": "[concat(variables('tierName').hostserver, '-resources')]",
            "type": "Microsoft.Resources/deployments",
            "apiVersion": "[variables('commonSettings').constants.apiVersions.deployments]",
            "dependsOn": [
                "[concat('Microsoft.Resources/deployments/', 'shared-resources')]"
            ],
            "properties": {
                "mode": "Incremental",
                "templateLink": {
                    "uri": "[concat(variables('commonSettings').repositoryUrl, 'ARM/hostserver.json')]",
                    "contentVersion": "1.0.0.0"
                },
                "parameters": {
                    "commonSettings": { "value": "[variables('commonSettings')]" }
                }
            }
        }
    ]
}

hostserver.json

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": { "commonSettings": { "type": "object" } },
    "variables": {
        "nlbname": "[concat('loadbalancer-', 'hostserver', '-', parameters('commonSettings').tenantName)]"
    },
    "resources": [
        {
            "type": "Microsoft.Network/loadBalancers",
            "name": "[variables('nlbname')]",
            "location": "[resourceGroup().location]",
            "apiVersion": "[parameters('commonSettings').constants.apiVersions.loadBalancers]",
            "properties": {
                "frontendIPConfigurations": [
                    {
                        "name": "myLoadBalancerFrontEnd",
                        "properties": {
                            "publicIPAddress": {
                                "id": "[parameters('commonSettings').ipAddressId.hostserver]"
                            }
                        }
                    }
				]
				...
            }
        },
        {
            "type": "Microsoft.Storage/storageAccounts",
            "apiVersion": "[parameters('commonSettings').constants.apiVersions.storageAccounts]",
			"location": "[resourceGroup().location]",
			...
        },
        {
            "type": "Microsoft.Compute/virtualMachineScaleSets",
            "apiVersion": "[parameters('commonSettings').constants.apiVersions.virtualMachineScaleSets]",
            "location": "[resourceGroup().location]",
            "name": "[concat('vmss-', parameters('commonSettings').tenantName, '-', 'hostserver')]",
            "sku": {
                "name": "[parameters('commonSettings').vm.size.hostserver]",
                "tier": "Standard",
                "capacity": "[parameters('commonSettings').hostserverInstanceCount]"
			},
			...
        }
    ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment