0

我能够使用 ARM 模板成功创建 Sql Server、Sql 数据库、sql 弹性池。但是当我尝试使用现有弹性池名称创建新数据库时。我得到以下错误。

如果没有弹性池 ID,则数据库创建成功。

Sql 数据库弹性池和数据库都使用相同的位置、层、版本等。此外,在 azure 门户中尝试时,它创建成功。

 "error": {
"code": "ResourceDeploymentFailure",
"message": "The resource operation completed with terminal provisioning state 'Failed'.",
"details": [
  {
    "code": "ElasticPoolSkuCombinationInvalid",
    "message": "Elastic pool 'sqlsamplepool' and sku 'Basic' combination is invalid."
  }
]

ARM 模板:

 {
 "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
 "parameters": {
  "collation": {
  "type": "string",
  "metadata": {
    "description": "The collation of the database."
  },
  "defaultValue": "SQL_Latin1_General_CP1_CI_AS"
},
"skutier": {
  "type": "string",
  "metadata": {
    "description": "The edition of the database. The DatabaseEditions enumeration contains all the 
    valid editions. e.g. Basic, Premium."
  },
  "allowedValues": [ "Basic", "Standard", "Premium" ],
  "defaultValue": "Basic"
},
"resourcelocation": {
  "type": "string",
  "defaultValue": "[resourceGroup().location]",
  "metadata": {
    "description": "Location for all resources."
  }
},
"sqlservername": {
  "type": "string",
  "metadata": {
    "description": "The name of the sql server."
  }
},
"zoneRedundant": {
  "type": "bool",
  "metadata": {
    "description": "Whether or not this database is zone redundant, which means the replicas of this database will be spread across multiple availability zones."
  },
  "defaultValue": false
},
"sqlElasticPoolName": {
  "type": "string",
  "metadata": {
    "description": "The Elastic Pool name."
  }
},
"databaseName": {
  "type": "string"
}
 },
 "functions": [],
"variables": {  },
  "resources": [
{
  "type": "Microsoft.Sql/servers/databases",
  "apiVersion": "2020-08-01-preview",
  "name": "[concat(parameters('sqlservername'),'/',parameter('databaseName'))]",
  "location": "[parameters('resourcelocation')]",
  "sku": {
    "name": "[parameters('skutier')]",
    "tier": "[parameters('skutier')]"
  },
  "properties": {
    "collation": "[parameters('collation')]",
    "zoneRedundant": "[parameters('zoneRedundant')]",
  "elasticPoolId":"[concat('/subscriptions/',subscription().subscriptionId,'/resourceGroups/',resourceGroup().name,'/providers/Microsoft.Sql/servers/',parameters('sqlservername'),'/elasticPools/',parameters('sqlElasticPoolName'))]"
  }
 }
]
}
4

1 回答 1

0

我不确定“2020-08-01-preview”版本有什么问题,但它在稳定版本中运行良好。下面是我工作的部分手臂模板代码。

我更改为 2014-04-01 api 版本。

  "comments": "If Elastic Pool Name is defined, then curent database will be added to elastic pool.",
  "type": "Microsoft.Sql/servers/databases",
  "apiVersion": "2014-04-01",
  "name": "[concat(parameters('sqlservername'),'/',variables('dbname'))]",
  "location": "[parameters('resourcelocation')]",
  "properties": {
    "collation": "[parameters('collation')]",
    "zoneRedundant": "[parameters('zoneRedundant')]",
    "elasticPoolName":"[if(not(empty(parameters('sqlElasticPoolName'))),parameters('sqlElasticPoolName'),'')]",
    "edition": "[parameters('skutier')]"
  }
于 2021-01-12T05:59:19.853 回答