Skip to content

Instantly share code, notes, and snippets.

@davoodharun
Created January 23, 2017 22:34
Show Gist options
  • Save davoodharun/8aeac408dbd9ce69e23fadeb35f95501 to your computer and use it in GitHub Desktop.
Save davoodharun/8aeac408dbd9ce69e23fadeb35f95501 to your computer and use it in GitHub Desktop.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"addressPrefix": {
"type": "string",
"defaultValue": "10.0.0.0/16",
"metadata": {
"description": "Address prefix for the Virtual Network"
}
},
"virtualNetworkName": {
"type": "string",
"metadata": {
"description": "Address prefix for the Virtual Network"
}
},
"subnetPrefix": {
"type": "string",
"defaultValue": "10.0.0.0/28",
"metadata": {
"description": "Subnet prefix"
}
},
"skuName": {
"type": "string",
"allowedValues": [
"Standard_Small",
"Standard_Medium",
"Standard_Large"
],
"defaultValue": "Standard_Medium",
"metadata": {
"description": "Sku Name"
}
},
"capacity": {
"type": "int",
"minValue": 1,
"maxValue": 10,
"defaultValue": 2,
"metadata": {
"description": "Number of instances"
}
},
"backendIpsForPathRuleDEL": {
"type": "array",
"metadata": {
"description": "IP Address of Backend Server for Path Rule 1 match"
}
},
"backendIpsForPathRuleSHR": {
"type": "array",
"metadata": {
"description": "IP Address of Backend Server for Path Rule 2 match"
}
},
"pathMatch1": {
"type": "string",
"metadata": {
"description": "Path match string for Path Rule 1"
}
},
"pathMatch2": {
"type": "string",
"metadata": {
"description": "Path match string for Path Rule 2"
}
}
},
"variables": {
"applicationGatewayName": "applicationGateway1",
"publicIPAddressName": "publicIpag",
"virtualNetworkName": "[parameters('virtualNetworkName')]",
"subnetName": "appGatewaySubnet",
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]",
"subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]",
"publicIPRef": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]",
"applicationGatewayID": "[resourceId('Microsoft.Network/applicationGateways',variables('applicationGatewayName'))]",
"apiVersion": "2015-06-15"
},
"resources": [
{
"apiVersion": "[variables('apiVersion')]",
"type": "Microsoft.Network/publicIPAddresses",
"name": "[variables('publicIPAddressName')]",
"location": "[resourceGroup().location]",
"properties": {
"publicIPAllocationMethod": "Dynamic"
}
},
{
"apiVersion": "[variables('apiVersion')]",
"name": "[variables('applicationGatewayName')]",
"type": "Microsoft.Network/applicationGateways",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]"
],
"properties": {
"sku": {
"name": "[parameters('skuName')]",
"tier": "Standard",
"capacity": "[parameters('capacity')]"
},
"gatewayIPConfigurations": [
{
"name": "appGatewayIpConfig",
"properties": {
"subnet": {
"id": "[variables('subnetRef')]"
}
}
}
],
"frontendIPConfigurations": [
{
"name": "appGatewayFrontendPublicIP",
"properties": {
"PublicIPAddress": {
"id": "[variables('publicIPRef')]"
}
}
}
],
"frontendPorts": [
{
"name": "appGatewayFrontendPort80",
"properties": {
"Port": 80
}
}
],
"backendAddressPools": [
{
"name": "appGatewayBackendPoolDefault",
"properties": {
"BackendAddresses": "[parameters('backendIpsForPathRuleDEL')]"
}
},
{
"name": "appGatewayBackendPool1",
"properties": {
"BackendAddresses": "[parameters('backendIpsForPathRuleDEL')]"
}
},
{
"name": "appGatewayBackendPool2",
"properties": {
"BackendAddresses": "[parameters('backendIpsForPathRuleSHR')]"
}
}
],
"backendHttpSettingsCollection": [
{
"name": "appGatewayBackendHttpSettings",
"properties": {
"Port": 80,
"Protocol": "Http",
"CookieBasedAffinity": "Disabled"
}
}
],
"httpListeners": [
{
"name": "appGatewayHttpListener",
"properties": {
"FrontendIPConfiguration": {
"Id": "[concat(variables('applicationGatewayID'), '/frontendIPConfigurations/appGatewayFrontendPublicIP')]"
},
"FrontendPort": {
"Id": "[concat(variables('applicationGatewayID'), '/frontendPorts/appGatewayFrontendPort80')]"
},
"Protocol": "Http",
"SslCertificate": null
}
}
],
"urlPathMaps": [
{
"name": "urlPathMap1",
"properties": {
"defaultBackendAddressPool": {
"id": "[concat(variables('applicationGatewayID'), '/backendAddressPools/appGatewayBackendPoolDefault')]"
},
"defaultBackendHttpSettings": {
"id": "[concat(variables('applicationGatewayID'), '/backendHttpSettingsCollection/appGatewayBackendHttpSettings')]"
},
"pathRules": [
{
"name": "pathRule1",
"properties": {
"paths": [
"[parameters('pathMatch1')]"
],
"backendAddressPool": {
"id": "[concat(variables('applicationGatewayID'), '/backendAddressPools/appGatewayBackendPool1')]"
},
"backendHttpSettings": {
"id": "[concat(variables('applicationGatewayID'), '/backendHttpSettingsCollection/appGatewayBackendHttpSettings')]"
}
}
},
{
"name": "pathRule2",
"properties": {
"paths": [
"[parameters('pathMatch2')]"
],
"backendAddressPool": {
"id": "[concat(variables('applicationGatewayID'), '/backendAddressPools/appGatewayBackendPool2')]"
},
"backendHttpSettings": {
"id": "[concat(variables('applicationGatewayID'), '/backendHttpSettingsCollection/appGatewayBackendHttpSettings')]"
}
}
}
]
}
}
],
"requestRoutingRules": [
{
"Name": "rule1",
"properties": {
"RuleType": "PathBasedRouting",
"httpListener": {
"id": "[concat(variables('applicationGatewayID'), '/httpListeners/appGatewayHttpListener')]"
},
"urlPathMap": {
"id": "[concat(variables('applicationGatewayID'), '/urlPathMaps/urlPathMap1')]"
}
}
}
]
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment