在ARM模板中部署App Service和slots时,可以使用以下示例代码来解决问题:
{
"name": "[variables('appServiceName')]",
"type": "Microsoft.Web/sites",
"apiVersion": "2016-08-01",
"location": "[parameters('location')]",
"dependsOn": [],
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]",
"siteConfig": {
"appSettings": [
{
"name": "SLOT_NAME",
"value": "[variables('slotName')]"
}
],
"alwaysOn": true
}
}
},
{
"name": "[variables('appServiceName')/slots/default]",
"type": "Microsoft.Web/sites/slots",
"apiVersion": "2016-08-01",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', variables('appServiceName'))]"
],
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]",
"siteConfig": {
"appSettings": [
{
"name": "SLOT_NAME",
"value": "default"
}
],
"alwaysOn": true
}
}
}
{
"name": "[variables('appServicePlanName')]",
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2018-02-01",
"location": "[parameters('location')]",
"sku": {
"name": "[parameters('appServicePlanSku')]",
"tier": "[parameters('appServicePlanTier')]",
"size": "[parameters('appServicePlanSize')]"
},
"properties": {
"name": "[variables('appServicePlanName')]",
"workerSize": "[parameters('appServicePlanWorkerSize')]"
}
}
"parameters": {
"location": {
"type": "string",
"defaultValue": "China North",
"metadata": {
"description": "The location of the resources."
}
},
"appServicePlanSku": {
"type": "string",
"defaultValue": "B1",
"metadata": {
"description": "The SKU of the App Service Plan."
}
},
"appServicePlanTier": {
"type": "string",
"defaultValue": "Basic",
"metadata": {
"description": "The tier of the App Service Plan."
}
},
"appServicePlanSize": {
"type": "string",
"defaultValue": "B1",
"metadata": {
"description": "The size of the App Service Plan."
}
},
"appServicePlanWorkerSize": {
"type": "string",
"defaultValue": "0",
"metadata": {
"description": "The worker size of the App Service Plan."
}
}
}
以上示例代码可以帮助您在ARM模板中部署App Service和slots,并设置相应的配置。您可以根据自己的需求进行调整和修改。