【发布时间】:2019-07-15 23:56:03
【问题描述】:
根据Microsoft Documentation,现在可以创建资源组并将资源部署到新创建的资源组。不过有一个小问题,在一开始,我们有这个免责声明 -
订阅级部署与资源组部署在以下几个方面有所不同:
架构和命令
您用于订阅级部署的架构和命令不同于资源组部署。
对于架构,使用https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#
这引发了一个重大问题,azuredeploy.json 不再被识别为部署模板,因为它没有使用资源部署架构 (https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#)。
因此,另一种选择是将资源组创建为 嵌套模板 并为将要被创建后,这现在允许我部署/验证文件。然而,这又带来了一个新问题。即使dependsOn 指示创建了资源组,它仍然无法识别这一点并返回错误 - 找不到资源组,因此无法部署资源。我尝试使用链接模板(我知道这没有任何区别,但仍然)
任何人,有没有机会做到这一点?
- 同时创建资源组和部署资源。
- 克服了尝试使用 DependsOn 的障碍,但仍未获得正确的部署或验证?
添加我的代码。
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"defaultValue": "North Europe"
},
"FirstResourceGroupName": {
"type": "string",
"defaultValue": "myFirstRG"
},
"FirstBlobStorageName": {
"type": "string",
"defaultValue": "North Europe"
}
},
"variables": {
},
"resources": [
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2018-05-01",
"name": "ResourceGroupDeployment",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.1",
"resources": [
{
"type": "Microsoft.Resources/resourceGroups",
"apiVersion": "2018-05-01",
"location": "[parameters('location')]",
"name": "[parameters('FirstResourceGroupName')]",
"properties": {}
}
],
"outputs" : {}
}
}
},
{
//ResourceDeployment
"type": "Microsoft.Resources/deployments",
"name": "StorageDeployment",
"apiVersion": "2017-05-10",
"dependsOn": [
"[concat('Microsoft.Resources/deployments/', 'ResourceGroupDeployment')]"
//"ResourceGroupDeployment"
],
"resourceGroup": "[parameters('FirstResourceGroupName')]",
"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",
"apiVersion": "2017-10-01",
"name": "[parameters('FirstBlobStorageName')]",
"location": "[parameters('location')]",
"kind": "StorageV2",
"sku": {
"name": "Standard_LRS"
}
}
],
"outputs": {}
}
}
}
],
"outputs": {}
}
【问题讨论】:
标签: azure azure-resource-manager azure-deployment