我尝试将现有服务计划附加到Azure Resource Manager模板中的新Web App。服务计划已经启动并且正在运行,而不是该臂模板的一部分
答案 0 :(得分:1)
您现在可能已经知道了这一点,但是如果有人像我一样点击了此线程,我将其发布。
您可以使用resourceId function引用现有的服务计划。
然后只需在模板中serverFarmId
的属性中使用它即可。
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]"
}
因此,基本上可以像Fei Han的示例所示,但是您需要删除dependsOn
(当然也要删除服务计划资源)。
答案 1 :(得分:1)
我的服务计划位于不同的资源组中,因此我还必须提供RG名称
“ serverFarmId”:“ [resourceId('plangroup', 'Microsoft.Web / serverfarms',parameters('hostingPlanName'))]“
答案 2 :(得分:0)
我正在尝试将Web服务计划附加到Auzre Resource Manager模板中的新Web App。服务计划不是由同一模板
创建的
您说服务计划没有创建,是不是现有的服务计划?如果您希望通过Azure PowerShell使用资源管理器模板将应用服务计划和Web应用部署到Azure,请参阅以下ARM模板。
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"hostingPlanName": {
"type": "string",
"minLength": 1
},
"skuName": {
"type": "string",
"defaultValue": "F1",
"allowedValues": [
"F1",
"D1",
"B1",
"B2",
"B3",
"S1",
"S2",
"S3",
"P1",
"P2",
"P3",
"P4"
],
"metadata": {
"description": "Describes plan's pricing tier and instance size. Check details at https://azure.microsoft.com/en-us/pricing/details/app-service/"
}
},
"skuCapacity": {
"type": "int",
"defaultValue": 1,
"minValue": 1,
"metadata": {
"description": "Describes plan's instance count"
}
},
"webSiteName": {
"type": "string",
"minLength": 1
}
},
"resources": [
{
"apiVersion": "2015-08-01",
"name": "[parameters('hostingPlanName')]",
"type": "Microsoft.Web/serverfarms",
"location": "[resourceGroup().location]",
"tags": {
"displayName": "HostingPlan"
},
"sku": {
"name": "[parameters('skuName')]",
"capacity": "[parameters('skuCapacity')]"
},
"properties": {
"name": "[parameters('hostingPlanName')]"
}
},
{
"apiVersion": "2015-08-01",
"name": "[parameters('webSiteName')]",
"type": "Microsoft.Web/sites",
"location": "[resourceGroup().location]",
"tags": {
"[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]": "Resource",
"displayName": "Website"
},
"dependsOn": [
"[concat('Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]"
],
"properties": {
"name": "[parameters('webSiteName')]",
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]"
}
}
]
}