我正在尝试创建一个ARM部署,用于创建或更新资源组、应用程序服务计划、应用程序洞察和应用程序服务。
我正在使用Azure管道在订阅范围内执行此部署。
这些资源都不存在,只有订阅。我已经将dependsOn
值放在除资源组之外的所有资源上,因此据我所知,它应该首先创建它。
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"application": {
"type": "string"
},
"location": {
"type": "string",
"allowedValues": [
"north europe",
"west europe"
]
},
"environment": {
"type": "string",
"allowedValues": [
"dev",
"fea",
"int",
"pre",
"prd"
]
},
"severity": {
"type": "string",
"allowedValues": [
"low",
"medium",
"high",
"critical"
]
},
"hostingPlanSkuTier": {
"type": "string",
"allowedValues": [
"Basic",
"Standard"
]
},
"hostingPlanSkuName": {
"type": "string",
"allowedValues": [
"B1",
"B2",
"B3",
"S1",
"S2",
"S3"
]
},
"hostingPlanSkuCapacity": {
"type": "int"
}
},
"variables": {
"resourceGroup": "[concat('rg-', parameters('application'), '-', parameters('environment'), '-', first(first(split(parameters('location'), ' '))), first(last(split(parameters('location'), ' '))))]",
"appServicePlan": "[concat('asp-', parameters('application'), '-', parameters('environment'), '-', first(first(split(parameters('location'), ' '))), first(last(split(parameters('location'), ' '))))]",
"appService": "[concat('as-', parameters('application'), '-', parameters('environment'), '-', first(first(split(parameters('location'), ' '))), first(last(split(parameters('location'), ' '))))]",
"ApplicationInsights": "[concat('ai-', parameters('application'), '-', parameters('environment'), '-', first(first(split(parameters('location'), ' '))), first(last(split(parameters('location'), ' '))))]"
},
"resources": [
{
"type": "Microsoft.Resources/resourceGroups",
"apiVersion": "2021-04-01",
"name": "[variables('resourceGroup')]",
"location": "[parameters('location')]",
"tags": {
"location": "[parameters('location')]",
"environment": "[parameters('environment')]",
"severity": "[parameters('severity')]"
}
},
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2022-03-01",
"name": "[variables('appServicePlan')]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Web/resourceGroups', variables('resourceGroup'))]"
],
"tags": {
"location": "[parameters('location')]",
"environment": "[parameters('environment')]",
"severity": "[parameters('severity')]"
},
"sku": {
"name": "[parameters('hostingPlanSkuName')]",
"tier": "[parameters('hostingPlanSkuTier')]",
"size": "[parameters('hostingPlanSkuName')]",
"family": "B",
"capacity": "[parameters('hostingPlanSkuCapacity')]"
},
"kind": "app",
"properties": {
"zoneRedundant": false
}
},
{
"type": "Microsoft.Insights/components",
"apiVersion": "2020-02-02",
"name": "[variables('ApplicationInsights')]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Web/resourceGroups', variables('resourceGroup'))]"
],
"tags": {
"location": "[parameters('location')]",
"environment": "[parameters('environment')]",
"severity": "[parameters('severity')]"
},
"kind": "web",
"properties": {
"Application_Type": "web"
}
},
{
"type": "Microsoft.Web/sites",
"apiVersion": "2022-03-01",
"name": "[variables('appService')]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', variables('resourceGroup'))]",
"[resourceId('Microsoft.Insights/components', variables('resourceGroup'))]"
],
"tags": {
"location": "[parameters('location')]",
"environment": "[parameters('environment')]",
"severity": "[parameters('severity')]"
},
"kind": "app",
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlan'))]",
"siteConfig": {
"appSettings": [
{
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
"value": "[reference(variables('ApplicationInsights'), '2020-02-02').InstrumentationKey]"
},
{
"name": "ApplicationInsightsAgent_EXTENSION_VERSION",
"value": "~2"
}
]
}
}
}
]
}
1条答案
按热度按时间nlejzf6q1#
资源"Microsoft. Web/resourceGroups/*"未定义
在ARM模板中,您将定义资源类型:
Microsoft.Resources/resourceGroups
作为第一资源。要设置下一个资源中的dependsOn字段,您需要调用以下资源id:
Microsoft.Resources/resourceGroups
例如: