Skip to content

Instantly share code, notes, and snippets.

@tspascoal
Created January 16, 2019 19:59
Show Gist options
  • Save tspascoal/db63664033f6f759276dc022795f9109 to your computer and use it in GitHub Desktop.
Save tspascoal/db63664033f6f759276dc022795f9109 to your computer and use it in GitHub Desktop.
ARM template for a web app with variable slots
{
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"webAppName": {
"type": "string"
},
"webAppSKU": {
"type": "string",
"defaultValue": "F1",
"allowedValues": [
"F1",
"D1",
"B1",
"B2",
"B3",
"S1",
"S2",
"S3",
"P1",
"P2",
"P3",
"P1V2",
"P2V2",
"P3V2"
]
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]"
},
"hostingPlanName": {
"type": "string",
"defaultValue": "[concat(parameters('webAppName'),'-plan', uniqueString(resourceGroup().name))]"
},
"numberWorkers": {
"type": "int",
"defaultValue": 1
},
"slotNumberWorkers": {
"type": "int",
"defaultValue": 1
},
"alwaysOn": {
"type": "bool",
"defaultValue": true
},
"httpsOnly": {
"type": "bool",
"defaultValue": true
},
"slots": {
"type": "array",
"defaultValue": []
}
},
"variables": {
"internalSlots": "[if(equals(0, length(parameters('slots'))) , createArray('__dummy') , parameters('slots') )]"
},
"resources": [
{
"name": "[parameters('webAppName')]",
"type": "Microsoft.Web/sites",
"apiVersion": "2018-02-01",
"location": "[parameters('location')]",
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]",
"numberWorkers": "[parameters('numberWorkers')]",
"siteConfig": {
"httpsOnly": "[parameters('httpsOnly')]",
"appSettings": [],
"connectionStrings": []
},
"alwaysOn": "[parameters('alwaysOn')]"
},
"dependsOn": [
"[parameters('hostingPlanName')]"
]
},
{
"condition": "[not(equals('__dummy', variables('internalSlots')[copyIndex()]))]",
"name": "[concat(parameters('webAppName'), '/', variables('internalSlots')[copyIndex()])]",
"type": "Microsoft.Web/sites/slots",
"apiVersion": "2018-02-01",
"location": "[parameters('location')]",
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]",
"numberWorkers": "[parameters('slotNumberWorkers')]",
"siteConfig": {
"httpsOnly": "[parameters('httpsOnly')]",
"appSettings": [],
"connectionStrings": []
},
"alwaysOn": "[parameters('alwaysOn')]"
},
"copy": {
"name": "slotIndex",
"count": "[length(variables('internalSlots'))]"
},
"dependsOn": [
"[parameters('hostingPlanName')]",
"[parameters('webAppName')]"
]
},
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2018-02-01",
"name": "[parameters('hostingPlanName')]",
"location": "[parameters('location')]",
"sku": {
"name": "[parameters('webAppSKU')]"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment