我在ARM中有以下资源
{
"name": "[parameters('dbServerName')]",
"type": "Microsoft.Sql/servers",
"location": "[resourceGroup().location]",
"tags": {
"displayName": "SqlServer"
},
"apiVersion": "2014-04-01-preview",
"properties": {
"administratorLogin": "[parameters('dbuser')]",
"administratorLoginPassword": "[parameters('dbpassword')]",
"version": "12.0"
},
"resources": [
{
"name": "[parameters('dbName')]",
"type": "databases",
"location": "[resourceGroup().location]",
"tags": {
"displayName": "[parameters('dbName')]"
},
"apiVersion": "2014-04-01-preview",
"dependsOn": [
"[parameters('dbServerName')]"
],
"properties": {
"edition": "[parameters('edition')]",
"collation": "[parameters('collation')]",
"maxSizeBytes": "[parameters('maxSizeBytes')]",
"requestedServiceObjectiveName": "[parameters('requestedServiceObjectiveName')]"
}
},
{
"name": "[parameters('hivedbName')]",
"type": "databases",
"location": "[resourceGroup().location]",
"tags": {
"displayName": "[parameters('hivedbName')]"
},
"apiVersion": "2014-04-01-preview",
"dependsOn": [
"[parameters('dbServerName')]"
],
"properties": {
"edition": "[parameters('edition')]",
"collation": "[parameters('collation')]",
"maxSizeBytes": "[parameters('maxSizeBytes')]",
"requestedServiceObjectiveName": "[parameters('requestedServiceObjectiveName')]"
}
},
{
"name": "[parameters('ooziedbName')]",
"type": "databases",
"location": "[resourceGroup().location]",
"tags": {
"displayName": "[parameters('ooziedbName')]"
},
"apiVersion": "2014-04-01-preview",
"dependsOn": [
"[parameters('dbServerName')]"
],
"properties": {
"edition": "[parameters('edition')]",
"collation": "[parameters('collation')]",
"maxSizeBytes": "[parameters('maxSizeBytes')]",
"requestedServiceObjectiveName": "[parameters('requestedServiceObjectiveName')]"
}
},
{
"type": "firewallrules",
"apiVersion": "2014-04-01-preview",
"dependsOn": [
"[parameters('dbServerName')]"
],
"location": "[resourceGroup().location]",
"name": "AllowAllWindowsAzureIps",
"properties": {
"endIpAddress": "0.0.0.0",
"startIpAddress": "0.0.0.0"
}
}
]
},
希望有另一个资源取决于上面所以我尝试在下一个资源中的dependson中添加以下内容
[concat('Microsoft.Sql/servers,'/',parameters('dbServerName'),'/databases/',parameters('hivedbName'))]
但是得到了以下错误:
New-AzureRmResourceGroupDeployment : 4:46:59 PM - Error: Code=InvalidTemplate; Message=Deployment template validation failed: 'Circular dependency detected on resource: '/subscriptions/######/resourceGroups/QA/providers/Microsoft.Sql/servers/sparkqa/databases/SparkQAHive'.
然后我试了
"dependsOn": [
"[concat('Microsoft.Sql/servers/', parameters('dbServerName'))]",
"[concat('Microsoft.Sql/servers,'/',parameters('dbServerName'),'/databases/',parameters('hivedbName'))]"
],
但是在创建concat('Microsoft.Sql/servers,'/',parameters('dbServerName'),'/databases/',parameters('hivedbName'))
之前它仍然开始部署资源
以下是完整的模板https://paste.fedoraproject.org/454465/14767382/raw/
有人知道这里有什么不对吗?
答案 0 :(得分:0)
您应该依赖于实际资源,而不仅仅依赖于sql server名称:
"dependsOn": [
"[concat('Microsoft.Sql/servers/', parameters('serverName'))]"
],