Last active
April 1, 2020 15:22
-
-
Save MattJeanes/134d81580c45831336e9ae81bba70fcb to your computer and use it in GitHub Desktop.
Example deployment slots for both app service and function apps in Azure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", | |
"contentVersion": "1.0.0.0", | |
"parameters": { | |
}, | |
"variables": { | |
"appServicePlanName": "myapp-swaptest-asp", | |
"site_name": "myapp-swaptest-app", | |
"functionapp_name": "myapp-swaptest-func", | |
"stagingslot_name": "staging" | |
}, | |
"resources": [ | |
{ | |
"type": "Microsoft.Web/serverfarms", | |
"sku": { | |
"name": "S1" | |
}, | |
"kind": "app", | |
"name": "[variables('appServicePlanName')]", | |
"apiVersion": "2016-09-01", | |
"location": "[resourceGroup().location]", | |
"scale": null, | |
"properties": { | |
"name": "[variables('appServicePlanName')]", | |
"perSiteScaling": false, | |
"reserved": false, | |
"targetWorkerCount": 0, | |
"targetWorkerSizeId": 0 | |
}, | |
"dependsOn": [ | |
] | |
}, | |
{ | |
"type": "Microsoft.Web/sites", | |
"kind": "functionapp", | |
"name": "[variables('functionapp_name')]", | |
"apiVersion": "2016-08-01", | |
"location": "[resourceGroup().location]", | |
"scale": null, | |
"properties": { | |
"enabled": true, | |
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]" | |
}, | |
"dependsOn": [ | |
"[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]" | |
], | |
"resources": [ | |
{ | |
"type": "config", | |
"apiVersion": "2018-11-01", | |
"name": "/web", | |
"dependsOn": [ | |
"[resourceId('Microsoft.Web/sites', variables('functionapp_name'))]" | |
], | |
"properties": { | |
"alwaysOn": true, | |
"cors": { | |
"allowedOrigins": [ | |
"https://functions.azure.com", | |
"https://functions-staging.azure.com", | |
"https://functions-next.azure.com", | |
"https://production.com" | |
], | |
"supportCredentials": false | |
} | |
} | |
}, | |
{ | |
"apiVersion": "2015-08-01", | |
"name": "slotconfignames", | |
"type": "config", | |
"dependsOn": [ | |
"[resourceId('Microsoft.Web/sites', variables('functionapp_name'))]" | |
], | |
"properties": { | |
"appSettingNames": [ | |
"IsDisabled" | |
] | |
} | |
}, | |
{ | |
"type": "slots", | |
"apiVersion": "2018-11-01", | |
"name": "[concat('/', variables('stagingslot_name'))]", | |
"dependsOn": [ | |
"[resourceId('Microsoft.Web/sites', variables('functionapp_name'))]" | |
], | |
"location": "[resourceGroup().location]", | |
"kind": "functionapp", | |
"properties": { | |
"enabled": true, | |
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]", | |
"clientAffinityEnabled": false, | |
"httpsOnly": true | |
}, | |
"resources": [ | |
{ | |
"type": "config", | |
"apiVersion": "2018-11-01", | |
"name": "/web", | |
"dependsOn": [ | |
"[resourceId('Microsoft.Web/sites/slots', variables('functionapp_name'), variables('stagingslot_name'))]" | |
], | |
"properties": { | |
"alwaysOn": false, | |
"cors": { | |
"allowedOrigins": [ | |
"https://functions.azure.com", | |
"https://functions-staging.azure.com", | |
"https://functions-next.azure.com", | |
"https://staging.com" | |
], | |
"supportCredentials": false | |
}, | |
"http20Enabled": true | |
} | |
}, | |
{ | |
"apiVersion": "2015-08-01", | |
"name": "appsettings", | |
"type": "config", | |
"dependsOn": [ | |
"[resourceId('Microsoft.Web/sites/slots', variables('functionapp_name'), variables('stagingslot_name'))]" | |
], | |
"properties": { | |
"myslotvar": "2", | |
"FUNCTIONS_EXTENSION_VERSION": "~3", | |
"FUNCTIONS_EXTENSION_RUNTIME": "dotnet", | |
"FUNCTIONS_WORKER_RUNTIME": "dotnet", | |
"IsDisabled": "1" | |
} | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"type": "Microsoft.Web/sites", | |
"kind": "app", | |
"name": "[variables('site_name')]", | |
"apiVersion": "2015-08-01", | |
"location": "[resourceGroup().location]", | |
"tags": { | |
}, | |
"scale": null, | |
"properties": { | |
"enabled": true, | |
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]" | |
}, | |
"dependsOn": [ | |
"[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]" | |
], | |
"resources": [ | |
{ | |
"type": "config", | |
"name": "/web", | |
"apiVersion": "2016-08-01", | |
"location": "[resourceGroup().location]", | |
"tags": { | |
}, | |
"properties": { | |
"alwaysOn": true | |
}, | |
"dependsOn": [ | |
"[resourceId('Microsoft.Web/sites', variables('site_name'))]" | |
] | |
}, | |
{ | |
"apiVersion": "2015-08-01", | |
"name": "slotconfignames", | |
"type": "config", | |
"dependsOn": [ | |
"[resourceId('Microsoft.Web/sites', variables('site_name'))]" | |
], | |
"properties": { | |
"appSettingNames": [ | |
"WEBJOBS_STOPPED" | |
] | |
} | |
}, | |
{ | |
"type": "slots", | |
"apiVersion": "2018-11-01", | |
"location": "[resourceGroup().location]", | |
"name": "[concat('/', variables('stagingslot_name'))]", | |
"dependsOn": [ | |
"[resourceId('Microsoft.Web/sites', variables('site_name'))]" | |
], | |
"properties": { | |
"enabled": true, | |
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]", | |
"reserved": false, | |
"clientAffinityEnabled": false, | |
"httpsOnly": true | |
}, | |
"resources": [ | |
{ | |
"type": "config", | |
"name": "/web", | |
"apiVersion": "2018-11-01", | |
"dependsOn": [ | |
"[resourceId('Microsoft.Web/sites/slots', variables('site_name'), variables('stagingslot_name'))]" | |
], | |
"properties": { | |
"http20Enabled": true, | |
"webSocketsEnabled": true | |
} | |
}, | |
{ | |
"type": "config", | |
"name": "appsettings", | |
"apiVersion": "2015-08-01", | |
"dependsOn": [ | |
"[resourceId('Microsoft.Web/sites/slots', variables('site_name'), variables('stagingslot_name'))]" | |
], | |
"properties": { | |
"my_variable": "test", | |
"my_slot_variable": "test", | |
"WEBJOBS_STOPPED": "1" | |
} | |
} | |
] | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment