azure - 具有多个范围的嵌套 Arm 模板
问题描述
当我尝试通过 Arm 模板部署多个资源时,谁能帮助我解决我遇到的问题?由于我拥有不同级别的资源,因此我使用嵌套的 Arm 模板部署。我正在尝试创建以订阅级别为范围的新资源组和两个资源,即:Log Analytics 工作区和 Azure Sentinel,它们以资源组级别为范围。但是,当我运行 Powershell 命令 New-AzSubscriptionDeployment 时出现错误,如下所述:
New-AzDeployment:下午 3:20:48 - 错误:代码=无效模板;消息=部署模板验证失败:'资源'Microsoft.Resources/resourceGroups/duo'未在模板中定义。请参阅https://aka.ms/arm-template了解使用详情。New-AzDeployment:部署验证失败
我的模板包含在下面。我真的很感激任何人的帮助。
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"resourceGroupName": {
"type": "string",
"metadata": {
"description": "Name of resource group."
}
},
"resourceGroupLocation": {
"type": "string",
"metadata": {
"description": "Location of resource group."
}
},
"workspaceNamePrefix": {
"type": "string",
"metadata": {
"description": "Prefix used for naming Log Analytics workspace."
}
},
"azureSentinelSolutionNamePrefix": {
"type": "string",
"metadata": {
"description": "Prefix used for naming Sentinel Solution."
}
}
},
"variables": {
"workspaceName": "[concat(parameters('workspaceNamePrefix'), uniqueString(subscription().id, parameters('resourceGroupName')))]",
"azureSentinelSolutionName": "[concat(parameters('azureSentinelSolutionNamePrefix'), variables('workspaceName'))]",
"product": "OMSGallery/SecurityInsights",
"publisher": "Microsoft"
},
"resources": [
{
"type": "Microsoft.Resources/resourceGroups",
"apiVersion": "2020-06-01",
"location": "[parameters('resourceGroupLocation')]",
"name": "[parameters('resourceGroupName')]",
"properties": {}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2020-06-01",
"name": "NestedTemplate",
"resourceGroup": "[parameters('resourceGroupName')]",
"dependsOn": [
"[resourceId('Microsoft.Resources/resourceGroups', parameters('resourceGroupName'))]"
],
"properties": {
"expressionEvaluationOptions": {
"scope": "outer"
},
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-08-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
},
"Variables": {},
"resources": [
{
"type": "Microsoft.OperationalInsights/workspaces",
"apiVersion": "2020-08-01",
"name": "[variables('workspaceName')]",
"location": "[parameters('resourceGroupLocation')]",
"sku": {
"name": "pergb2018"
},
"dependsOn": [
"[resourceId('Microsoft.Resources/resourceGroups', parameters('resourceGroupName'))]"
]
},
{
"type": "Microsoft.OperationsManagement/solutions",
"apiVersion": "2015-11-01-preview",
"name": "[variables('azureSentinelSolutionName')]",
"location": "[parameters('resourceGroupLocation')]",
"plan": {
"name": "[variables('azureSentinelSolutionName')]",
"promotionCode": "",
"product": "[variables('product')]",
"publisher": "[variables('publisher')]"
},
"dependsOn": [
"[resourceId('Microsoft.OperationalInsights/workspaces', variables('workspaceName'))]",
"[resourceId('Microsoft.Resources/resourceGroups', parameters('resourceGroupName'))]"
],
"properties": {
"workspaceResourceId": "[resourceId('Microsoft.OperationalInsights/workspaces', variables('workspaceName'))]"
}
}
],
"outputs": {}
}
}
}
],
"outputs": {}
}
解决方案
推荐阅读
- flutter - 我想在相机屏幕选项卡上隐藏应用栏和底部导航栏
- python - 获取queryset django时添加功能
- google-cloud-firestore - 如何使用安全规则限制地火采石场的范围?
- php - 在 Laravel 中按名称进行数组分组
- swift - 防止 List 中的最后一行被 ZStack 中的其他视图覆盖
- javascript - 使用 vm.$watch() 多次而不是一次处理多个回调?
- python - 如何在 django-rest-framework 的序列化程序中使用时区序列化时间?
- javascript - 获取 url img 数据并将其设置在我的 html 中 img 的 src 属性中
- sql - 如何检查两个用户是否有私人聊天?SQL
- python - 如何将 tf 模型预测与层相关联?