And*_*erb 5 azure iaas azure-resource-manager
有谁知道如何将ARM模板中的资源放入特定的不同资源组?这可能是一个RG中的存储和另一个RG中的网络,两者都是在相同或不同的模板中创建的(例如,嵌套).
详情如下.
阅读最佳实践指南ARM模板最佳实践和白皮书世界级ARM模板注意事项和经验证实践,建议部署的不同元素应位于不同的资源组中.例如,在IaaS解决方案中,您的DC可能位于Admin RG中,后端服务器位于另一个中,而您的客户端桌面位于第三个.
我目前正在尝试通过嵌套模板部署这样的解决方案,我偶然发现了一个问题,即创建的所有项目都会自动放置在关闭进程时选择的资源组内(即父模板).我在线查看了各种文档,但显然无法找到将模板中创建的资源强制到特定资源组的方法.有没有人这样做过?
无法从模板将资源部署到多个资源组中.仅仅因为Azure Resource Manager REST API Reference只有一个地方来指定资源组名称.
ARM模板的概念是您创建资源组并将模板部署到其中,从而提供单个管理单元来管理这些资源.这改进了Azure Service Management模型,您必须单独管理每个资源.
嵌套资源组可以满足您的需求,但我从来没有听说过为Azure计划过这样的事情.
对于在Google中找到此内容的其他任何人(像我一样):
现在可以在一个ARM模板中将资源部署到多个资源组。Microsoft在此处提供了详细信息:https : //docs.microsoft.com/zh-cn/azure/azure-resource-manager/resource-manager-cross-resource-group-deployment以获取详细信息。
为此,您在主模板中包括一个嵌套的部署模板,并将嵌套的部署设置为另一个资源组。这是来自MS网站的示例:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storagePrefix": {
"type": "string",
"maxLength": 11
},
"secondResourceGroup": {
"type": "string"
},
"secondSubscriptionID": {
"type": "string",
"defaultValue": ""
},
"secondStorageLocation": {
"type": "string",
"defaultValue": "[resourceGroup().location]"
}
},
"variables": {
"firstStorageName": "[concat(parameters('storagePrefix'), uniqueString(resourceGroup().id))]",
"secondStorageName": "[concat(parameters('storagePrefix'), uniqueString(parameters('secondSubscriptionID'), parameters('secondResourceGroup')))]"
},
"resources": [
{
"apiVersion": "2017-05-10",
"name": "nestedTemplate",
"type": "Microsoft.Resources/deployments",
"resourceGroup": "[parameters('secondResourceGroup')]",
"subscriptionId": "[parameters('secondSubscriptionID')]",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('secondStorageName')]",
"apiVersion": "2017-06-01",
"location": "[parameters('secondStorageLocation')]",
"sku":{
"name": "Standard_LRS"
},
"kind": "Storage",
"properties": {
}
}
]
},
"parameters": {}
}
},
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('firstStorageName')]",
"apiVersion": "2017-06-01",
"location": "[resourceGroup().location]",
"sku":{
"name": "Standard_LRS"
},
"kind": "Storage",
"properties": {
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2684 次 |
| 最近记录: |