Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
400 lines (399 sloc) 18.4 KB
/*
# Access granted under MIT Open Source License: https://en.wikipedia.org/wiki/MIT_License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions
# of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
# TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Created by: Brent Stineman
#
# Description: This file demonstrates the use of linked Azure Resource Manager (ARM) templates and techniques such
# as passing objects into and out of the various linked templates. It also demonstrates using parameters, variables,
# and objects to take a "generalized" input parameter (say: small, medium, large) and "explode" that into multiple
# detailed settings
#
# For more about these techniques, see: https://brentdacodemonkey.wordpress.com/2017/03/09/azure-resource-manager-template-tips-and-tricks/
#
# Modifications
# 2017/04/19 : Initial publication
#
*/
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"resourcePrefix": {
"type": "string",
"minLength": 6,
"maxLength": 6,
"metadata": {
"description": "The resource prefix (must be globally unique). only allows alpha characters."
}
},
"deploymentSize": {
"type": "string",
"defaultValue": "Small",
"allowedValues": [
"Dev (not for production)",
"Small",
"Medium",
"Large"
],
"metadata": {
"description": "The general size of the deployment"
}
},
"adminUser": {
"type": "string",
"metadata": {
"description": "The admin user"
}
},
"adminPassword": {
"type": "securestring",
"metadata": {
"description": "The password of the admin user"
}
},
"templateBaseURL": {
"type": "string",
"defaultValue": "[deployment().properties.templateLink.uri]",
"metadata": {
"description": "The base location for all linked templates."
}
},
"templateSASToken": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "The base location for all linked templates."
}
}
},
"variables": {
"deploymentAPI" : "2015-01-01",
"sqlServerName" : "[concat(parameters('resourcePrefix'), '-sql')]",
"ServiceBusNamespace" : "[concat(parameters('resourcePrefix'), '-sbQueues')]",
"DomainPrefix": "[concat(parameters('resourcePrefix'), '-web')]",
"StorageAccountName": "[parameters('resourcePrefix')]",
"dbTemplateURI": "[concat(uri(parameters('templateBaseURL'), 'deploy-db.json'), parameters('templateSASToken'))]",
"WebTemplateURI": "[concat(uri(parameters('templateBaseURL'), 'deploy-web.json'), parameters('templateSASToken'))]",
"StorageTemplateURI": "[concat(uri(parameters('templateBaseURL'), 'deploy-storageAccount.json'), parameters('templateSASToken'))]",
"ServiceBusTemplateURI": "[concat(uri(parameters('templateBaseURL'), 'deploy-servicebus.json'), parameters('templateSASToken'))]",
"VNetTemplateURI": "[concat(uri(parameters('templateBaseURL'), 'deploy-vnet.json'), parameters('templateSASToken'))]",
"jumpboxTemplateURI": "[concat(uri(parameters('templateBaseURL'), 'deploy-jumpbox.json'), parameters('templateSASToken'))]",
"lbVMTemplateURI": "[concat(uri(parameters('templateBaseURL'), 'deploy-loadbalancedvms.json'), parameters('templateSASToken'))]",
"svcfabTemplateURI": "[concat(uri(parameters('templateBaseURL'), 'deploy-servicefabric-1nt.json'), parameters('templateSASToken'))]",
"queuename" : "samplequeue",
"vNetSettings": {
"Name": "[concat(parameters('resourcePrefix'), '-vnet')]",
"addressPrefix": "10.0.0.0/16",
"subnetFrontEnd" : {
"Name": "FrontEnd",
"CIDR": "10.0.1.0/24"
},
"subnetBackEnd" : {
"Name": "BackEnd",
"CIDR": "10.0.2.0/24"
},
"subnetManagement" : {
"Name": "Management",
"CIDR": "10.0.3.0/24"
}
},
"svcFabSettings": {
"tcpGatewayPort": "19000",
"httpGatewayPort": "19080",
"reverseProxyPort": "19008",
"clusterPorts" : "1025-1027",
"applicationStartPort": "20000",
"applicationEndPort": "30000",
"ephemeralStartPort": "49152",
"ephemeralEndPort": "65534"
},
"frontEndAppPort": 80,
"rdpMachineIP": "10.0.3.4",
"servicefabricLBIP": "10.0.2.4",
/* map sizing */
"sizeParameters" : {
"Dev (not for production)" : {
"storageAccountType": "Standard_LRS",
"WebHostingPlan": "Basic",
"InstanceCount": 1,
"databaseSKU": "Basic",
"serviceBusTier": "Basic",
"serviceFabricNodeCount": 3,
"jumpboxVMSize": "Standard_A1",
"loadbalancedVMSize": "Standard_A1",
"loabalancedVMCount": 1,
"svcfab": {
"nodeSize" : "Standard_A1",
"durabilityLevel" :"Bronze",
"reliabilityLevel" : "Bronze",
"nodeInstanceCount" : 3
}
},
"Small" : {
"storageAccountType": "Standard_ZRS",
"WebHostingPlan": "Shared",
"InstanceCount": 1,
"databaseSKU": "Basic",
"serviceBusTier": "Basic",
"serviceFabricNodeCount": 5,
"jumpboxVMSize": "Standard_A1_v2",
"loadbalancedVMSize": "Standard_A1_v2",
"loabalancedVMCount": 2,
"svcfab": {
"nodeSize" : "Standard_A1_v2",
"durabilityLevel" :"Bronze",
"reliabilityLevel" : "Silver",
"nodeInstanceCount" : 5
}
},
"Medium" : {
"storageAccountType": "Standard_GRS",
"WebHostingPlan": "Standard S1",
"InstanceCount": 2,
"databaseSKU": "Standard S1",
"serviceBusTier": "Standard",
"serviceFabricNodeCount": 7,
"jumpboxVMSize": "Standard_D2_v2",
"loadbalancedVMSize": "Standard_A2_v2",
"loabalancedVMCount": 3,
"svcfab": {
"nodeSize" : "Standard_A1",
"durabilityLevel" :"Gold",
"reliabilityLevel" : "Silver",
"nodeInstanceCount" : 5
}
},
"Large" : {
"storageAccountType": "Standard_RAGRS",
"WebHostingPlan": "Premium P1",
"InstanceCount": 3,
"databaseSKU": "Premium P2",
"serviceBusTier": "Standard",
"serviceFabricNodeCount": 10,
"jumpboxVMSize": "Standard_D2_v2",
"loadbalancedVMSize": "Standard_D2_v2",
"loabalancedVMCount": 4,
"svcfab": {
"nodeSize" : "Standard_D4_v2",
"durabilityLevel" :"Gold",
"reliabilityLevel" : "Gold",
"nodeInstanceCount" : 7
}
}
}
},
"resources": [
{
"type": "Microsoft.Resources/deployments",
"name": "SQLDatabaseTemplate",
"apiVersion": "[variables('deploymentAPI')]",
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[variables('dbTemplateURI')]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"sqlServerName": { "value": "[variables('sqlServerName')]" },
"databaseName": { "value": "sample" },
"databaseSKU": { "value": "[variables('sizeParameters')[parameters('deploymentSize')]['databaseSKU']]" },
"sqlAdministratorLogin": { "value": "[parameters('adminUser')]" },
"sqlAdministratorPassword": { "value": "[parameters('adminPassword')]" }
}
}
},
{
"type": "Microsoft.Resources/deployments",
"name": "ServiceBusTemplate",
"apiVersion": "[variables('deploymentAPI')]",
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[variables('ServiceBusTemplateURI')]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"ServiceBusNamespace": { "value": "[variables('ServiceBusNamespace')]" },
"ServiceBusTier": { "value": "[variables('sizeParameters')[parameters('deploymentSize')]['serviceBusTier']]" },
"queueName": { "value": "[variables('queuename')]" }
}
}
},
{
"type": "Microsoft.Resources/deployments",
"name": "WebTemplate",
"apiVersion": "[variables('deploymentAPI')]",
"dependsOn": [
"SQLDatabaseTemplate",
"ServiceBusTemplate"
],
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[variables('WebTemplateURI')]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"DomainPrefix": { "value": "[variables('DomainPrefix')]" },
"WebHostingPlan": { "value": "[variables('sizeParameters')[parameters('deploymentSize')]['WebHostingPlan']]" },
"InstanceCount": { "value": "[variables('sizeParameters')[parameters('deploymentSize')]['InstanceCount']]" },
"sqlServerFQDN": { "value": "[reference('SQLDatabaseTemplate').outputs.databaseServerFQDN.value]" },
"sqlDatabaseName": { "value": "[reference('SQLDatabaseTemplate').outputs.databaseName.value]" },
"sqlAdministratorLogin": { "value": "[parameters('adminUser')]" },
"sqlAdministratorPassword": { "value": "[parameters('adminPassword')]" },
"svcbusSendPolicy": { "value": "[reference('ServiceBusTemplate').outputs.sendPolicy.value]" }
}
}
},
{
"type": "Microsoft.Resources/deployments",
"name": "Storage",
"apiVersion": "[variables('deploymentAPI')]",
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[variables('StorageTemplateURI')]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"storageAccountName": { "value": "[variables('StorageAccountName')]" },
"storageAccountType": { "value": "[variables('sizeParameters')[parameters('deploymentSize')]['storageAccountType']]" }
}
}
},
/* set up the VNet and compute resources */
{
"type": "Microsoft.Resources/deployments",
"name": "vnetTemplate",
"apiVersion": "[variables('deploymentAPI')]",
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[variables('VNetTemplateURI')]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"vNetSettings": { "value": "[variables('vNetSettings')]" },
"svcFabSettings": { "value": "[variables('svcFabSettings')]" },
"frontEndAppPort": { "value": "[variables('frontEndAppPort')]" },
"rdpMachineIP": { "value": "[variables('rdpMachineIP')]" }
}
}
},
{
"type": "Microsoft.Resources/deployments",
"name": "jumpboxTemplate",
"apiVersion": "[variables('deploymentAPI')]",
"dependsOn": [
"vnetTemplate"
],
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[variables('jumpboxTemplateURI')]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"resourcePrefix": { "value": "[concat(parameters('resourcePrefix'),'rdp')]" },
"vmSize": { "value": "[variables('sizeParameters')[parameters('deploymentSize')]['jumpboxVMSize']]" },
"adminUser": { "value": "[parameters('adminUser')]" },
"adminPassword": { "value": "[parameters('adminPassword')]" },
"subnetResourceId": { "value": "[reference('vnetTemplate').outputs.subnetIDs.value.management]" },
"privateIP" : { "value": "[variables('rdpMachineIP')]" },
"templateBaseURL": { "value": "[parameters('templateBaseURL')]" },
"templateSASToken": { "value": "[parameters('templateSASToken')]" }
}
}
},
{
"type": "Microsoft.Resources/deployments",
"name": "loadbalancedvmTemplate",
"apiVersion": "[variables('deploymentAPI')]",
"dependsOn": [
"vnetTemplate"
],
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[variables('lbVMTemplateURI')]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"resourcePrefix": { "value": "[concat(parameters('resourcePrefix'), 'fe')]" },
"vmSize": { "value": "[variables('sizeParameters')[parameters('deploymentSize')]['loadbalancedVMSize']]" },
"vmCount": { "value": "[variables('sizeParameters')[parameters('deploymentSize')]['loabalancedVMCount']]" },
"publicPort": { "value": "[variables('frontEndAppPort')]"},
"adminUser": { "value": "[parameters('adminUser')]" },
"adminPassword": { "value": "[parameters('adminPassword')]" },
"subnetResourceId": { "value": "[reference('vnetTemplate').outputs.subnetIDs.value.frontEnd]" },
"templateBaseURL": { "value": "[parameters('templateBaseURL')]" },
"templateSASToken": { "value": "[parameters('templateSASToken')]" }
}
}
},
{
"type": "Microsoft.Resources/deployments",
"name": "servicefabricTemplate",
"apiVersion": "[variables('deploymentAPI')]",
"dependsOn": [
"vnetTemplate"
],
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[variables('svcfabTemplateURI')]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"resourcePrefix": { "value": "[parameters('resourcePrefix')]" },
"nodeSize" : { "value": "[variables('sizeParameters')[parameters('deploymentSize')]['svcfab']['nodeSize']]" },
"durabilityLevel" : { "value": "[variables('sizeParameters')[parameters('deploymentSize')]['svcfab']['durabilityLevel']]" },
"reliabilityLevel" : { "value": "[variables('sizeParameters')[parameters('deploymentSize')]['svcfab']['reliabilityLevel']]" },
"nodeInstanceCount" : { "value": "[variables('sizeParameters')[parameters('deploymentSize')]['svcfab']['nodeInstanceCount']]" },
"svcFabSettings": { "value": "[variables('svcFabSettings')]"},
"adminUser": { "value": "[parameters('adminUser')]" },
"adminPassword": { "value": "[parameters('adminPassword')]" },
"subnetResourceId": { "value": "[reference('vnetTemplate').outputs.subnetIDs.value.backend]" },
"clusterGatewayIP": { "value": "[variables('servicefabricLBIP')]" },
"templateBaseURL": { "value": "[parameters('templateBaseURL')]" },
"templateSASToken": { "value": "[parameters('templateSASToken')]" }
}
}
}
],
"outputs": {
"WebSiteFQDN" : {
"type" : "string",
"value": "[reference('WebTemplate').Outputs.webSiteFQDN.value]"
},
"DatabaseServerFQDN" : {
"type" : "string",
"value": "[reference('SQLDatabaseTemplate').Outputs.databaseServerFQDN.value]"
},
"DatabaseName" : {
"type" : "string",
"value": "[reference('SQLDatabaseTemplate').Outputs.databaseName.value]"
},
"jumpboxFQDN" : {
"type" : "string",
"value": "[reference('jumpboxTemplate').Outputs.jumpboxFQDN.value]"
},
"loadbalancerFQDN" : {
"type" : "string",
"value": "[reference('loadbalancedvmTemplate').Outputs.loadbalancerFQDN.value]"
}
}
}