{ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "appServiceName": { "type": "string" }, "appServicePlanName": { "type": "string" }, "appServicePlanResourceGroup": { "type": "string" }, "appServiceAppSettings": { "type": "secureObject", "defaultValue": { "array": [] } }, "appServiceConnectionStrings": { "type": "secureObject", "defaultValue": { "array": [] } }, "appServiceVirtualApplications": { "type": "array", "defaultValue": [ { "virtualPath": "/", "physicalPath": "site\\wwwroot", "preloadEnabled": true, "virtualDirectories": null } ] }, "customHostName": { "type": "string", "defaultValue": "" }, "certificateThumbprint": { "type": "string", "defaultValue": "", "metadata": { "description": "This can be passed into the template via the reference function: [reference(resourceId(parameters('certificateResourceGroup'), 'Microsoft.Web/certificates', parameters('certificateName')), '2016-03-01').Thumbprint]" } }, "deployStagingSlot": { "type": "bool", "defaultValue": true }, "ipSecurityRestrictions": { "type": "array", "defaultValue": [], "metadata": { "description": "Format removing backlashes: [{\"Name\": \"IP A\",\"ipAddress\": \"123.123.123.123\"},{\"Name\": \"IP B\",\"ipAddress\": \"234.234.234.234\"}]" } }, "appServiceSlotAppSettings": { "type": "secureObject", "defaultValue": { "array": [] }, "metadata": { "description": "Use if any settings will be different between production and staging slots. Specify in the name of the setting in the SlotSetting parameters" } }, "appServiceSlotSettingAppSettings": { "type": "array", "defaultValue": [ "WEBSITE_LOCAL_CACHE_OPTION", "WEBSITE_LOCAL_CACHE_SIZEINMB" ], "metadata": { "description": "List of app settings to set as slot specific: [\"EnvironmentName\", \"ReadOnly\"]" } }, "appServiceSlotConnectionStrings": { "type": "secureObject", "defaultValue": { "array": [] }, "metadata": { "description": "Use if any settings will be different between production and staging slots. Specify in the name of the setting in the SlotSetting parameters" } }, "healthCheckPath": { "type": "string", "defaultValue": "", "metadata": { "description": "The path for the health check endpoint. Leave empty to disable health check." } }, "appServiceSlotSettingConnectionStrings": { "type": "array", "defaultValue": [], "metadata": { "description": "List of connection strings to set as slot specific: [\"Sql\", \"CosmosDb\", \"Redis\"]" } }, "appKind": { "type": "string", "defaultValue": "app", "allowedValues": [ "web", "app", "api" ] }, "subnetResourceId": { "type": "string", "defaultValue": "", "metadata": { "description": "Resource ID of the subnet used for vNet integration" } } }, "variables": { "appServiceProductionSlotAppSettings": [ { "name": "WEBSITE_LOCAL_CACHE_OPTION", "value": "Always" }, { "name": "WEBSITE_LOCAL_CACHE_SIZEINMB", "value": "1000" }, { "name": "WEBSITE_ADD_SITENAME_BINDINGS_IN_APPHOST_CONFIG", "value": 1 } ], "appServiceStagingSlotAppSettings": [ { "name": "WEBSITE_ADD_SITENAME_BINDINGS_IN_APPHOST_CONFIG", "value": 1 } ], "useCustomHostname": "[greater(length(parameters('customHostname')), 0)]", "appServicePlanId": "[resourceId(parameters('appServicePlanResourceGroup'), 'Microsoft.Web/serverfarms', parameters('appServicePlanName'))]", "useAppServiceSlotAppSettings": "[greater(length(parameters('appServiceSlotAppSettings').array), 0)]", "useAppServiceSlotConnectionStrings": "[greater(length(parameters('appServiceSlotConnectionStrings').array), 0)]", "useAppServiceStagingSlotAppSettingsCombined": "[union(parameters('appServiceSlotAppSettings').array, variables('appServiceStagingSlotAppSettings'))]", "appServiceApiVersion": "2018-11-01", "appServiceProductionSlotAppSettingsCombined": "[union(parameters('appServiceAppSettings').array, variables('appServiceProductionSlotAppSettings'))]", "appServiceStagingSlotAppSettingsCombined": "[union(parameters('appServiceAppSettings').array, variables('appServiceStagingSlotAppSettings'))]" }, "resources": [ { "name": "[parameters('appServiceName')]", "type": "Microsoft.Web/sites", "kind": "[parameters('appKind')]", "apiVersion": "[variables('appServiceApiVersion')]", "location": "[resourceGroup().location]", "identity": { "type": "SystemAssigned" }, "properties": { "serverFarmId": "[variables('appServicePlanId')]", "clientAffinityEnabled": false, "siteConfig": { "alwaysOn": true, "appSettings": "[variables('appServiceProductionSlotAppSettingsCombined')]", "connectionStrings": "[parameters('appServiceConnectionStrings').array]", "virtualApplications": "[parameters('appServiceVirtualApplications')]", "ipSecurityRestrictions": "[parameters('ipSecurityRestrictions')]", "minTlsVersion": "1.2", "ftpsState": "Disabled", "healthCheckPath": "[parameters('healthCheckPath')]" }, "httpsOnly": true }, "resources": [ { "condition": "[parameters('deployStagingSlot')]", "name": "staging", "type": "slots", "apiVersion": "2018-11-01", "location": "[resourceGroup().location]", "identity": { "type": "SystemAssigned" }, "properties": { "serverFarmId": "[variables('appServicePlanId')]", "clientAffinityEnabled": false, "siteConfig": { "appSettings": "[if(variables('useAppServiceSlotAppSettings'), variables('useAppServiceStagingSlotAppSettingsCombined'), variables('appServiceStagingSlotAppSettingsCombined'))]", "connectionStrings": "[if(variables('useAppServiceSlotConnectionStrings'), parameters('appServiceSlotConnectionStrings').array, parameters('appServiceConnectionStrings').array)]", "virtualApplications": "[parameters('appServiceVirtualApplications')]", "ipSecurityRestrictions": "[parameters('ipSecurityRestrictions')]", "minTlsVersion": "1.2", "ftpsState": "Disabled" }, "httpsOnly": true }, "dependsOn": [ "[parameters('appServiceName')]" ] }, { "condition": "[parameters('deployStagingSlot')]", "name": "slotconfignames", "type": "config", "apiVersion": "2018-11-01", "properties": { "appSettingNames": "[parameters('appServiceSlotSettingAppSettings')]", "connectionStringNames": "[parameters('appServiceSlotSettingConnectionStrings')]" }, "dependsOn": [ "[parameters('appServiceName')]" ] } ] }, { "type": "Microsoft.Web/sites/hostnameBindings", "condition": "[variables('UseCustomHostname')]", "name": "[concat(parameters('appServiceName'), '/', if(variables('useCustomHostname'), parameters('customHostname'), 'placeholder'))]", "apiVersion": "2018-11-01", "location": "[resourceGroup().location]", "properties": { "sslState": "SniEnabled", "thumbprint": "[parameters('certificateThumbprint')]" }, "dependsOn": [ "[resourceId('Microsoft.Web/sites', parameters('appServiceName'))]" ] }, { "type": "Microsoft.Web/sites/config", "condition": "[greater(length(parameters('subnetResourceId')), 0)]", "name": "[concat(parameters('appServiceName'), '/virtualNetwork')]", "apiVersion": "2018-11-01", "location": "[resourceGroup().location]", "properties": { "subnetResourceId": "[parameters('subnetResourceId')]", "swiftSupported": true }, "dependsOn": [ "[resourceId('Microsoft.Web/sites', parameters('appServiceName'))]" ] } ], "outputs": { "possibleOutboundIpAddresses": { "type": "array", "value": "[split(reference(parameters('appServiceName')).possibleOutboundIpAddresses, ',')]" }, "managedServiceIdentityId": { "type": "string", "value": "[reference(parameters('appServiceName'), variables('appServiceApiVersion'), 'Full').identity.principalId]" }, "stagingManagedServiceIdentityId": { "condition": "[parameters('deployStagingSlot')]", "type": "string", "value": "[reference('staging', variables('appServiceApiVersion'), 'Full').identity.principalId]" } } }