当前位置: 首页 > 知识库问答 >
问题:

使用运营模式部署ARM模板时出现奇怪错误

司徒隐水
2023-03-14

我有一个arm模板,可以创建2个文档数据库服务器。ARM模板的部分如下所示:

{
  "name": "[variables('sqlServerName')]",
  "type": "Microsoft.DocumentDB/databaseAccounts",
  "apiVersion": "2019-12-12",
  "location": "[parameters('location')]",
  "tags": {
    "name": "Cosmos DB Account"
  },
  "properties": {
    "locations": "[variables('locations')]",
    "databaseAccountOfferType": "Standard"
  }
},
{
  "name": "[variables('sqlServerDevelopmentName')]",
  "type": "Microsoft.DocumentDB/databaseAccounts",
  "apiVersion": "2019-12-12",
  "location": "[parameters('location')]",
  "tags": {
    "name": "Cosmos Development DB Account"
  },
  "properties": {
    "locations": "[variables('locations')]",
    "databaseAccountOfferType": "Standard"
  }
},
{
  "type": "Microsoft.DocumentDB/databaseAccounts/apis/databases",
  "name": "[concat(variables('sqlServerName'), '/sql/', variables('name'))]",
  "apiVersion": "2016-03-31",
  "dependsOn": ["[resourceId('Microsoft.DocumentDB/databaseAccounts/', variables('sqlServerName'))]"],
  "properties": {
    "resource": {
      "name": "[variables('liveName')]"
    },
    "options": {
      "throughput": "[variables('cosmosThroughPut')]"
    }
  }
},
{
  "type": "Microsoft.DocumentDB/databaseAccounts/apis/databases",
  "name": "[concat(variables('sqlServerDevelopmentName'), '/sql/', variables('name'))]",
  "apiVersion": "2016-03-31",
  "dependsOn": ["[resourceId('Microsoft.DocumentDB/databaseAccounts/', variables('sqlServerDevelopmentName'))]"],
  "properties": {
    "resource": {
      "name": "[variables('developmentName')]"
    },
    "options": {
      "throughput": "[variables('cosmosDevelopThroughPut')]"
    }
  }
},
{
  "name": "[concat(variables('sqlServerName'), '/sql/', variables('name'), '/', variables('cosmosContainerName'))]",
  "type": "Microsoft.DocumentDb/databaseAccounts/apis/databases/containers",
  "apiVersion": "2016-03-31",
  "dependsOn": ["[resourceId('Microsoft.DocumentDB/databaseAccounts/apis/databases', variables('sqlServerName'), 'sql', variables('name'))]"],
  "properties": {
    "resource": {
      "name": "[variables('cosmosContainerName')]",
      "partitionKey": {
        "paths": [
          "/categoryId"
        ],
        "kind": "Hash"
      },
      "indexingPolicy": {
        "indexingMode": "consistent",
        "includedPaths": [{
          "path": "/*"
        }]
      }
    }
  }
},
{
  "name": "[concat(variables('sqlServerDevelopmentName'), '/sql/', variables('name'), '/', variables('cosmosContainerName'))]",
  "type": "Microsoft.DocumentDb/databaseAccounts/apis/databases/containers",
  "apiVersion": "2016-03-31",
  "dependsOn": ["[resourceId('Microsoft.DocumentDB/databaseAccounts/apis/databases', variables('sqlServerDevelopmentName'), 'sql', variables('name'))]"],
  "properties": {
    "resource": {
      "name": "[variables('cosmosContainerName')]",
      "partitionKey": {
        "paths": [
          "/categoryId"
        ],
        "kind": "Hash"
      },
      "indexingPolicy": {
        "indexingMode": "consistent",
        "includedPaths": [{
          "path": "/*"
        }]
      }
    }
  }
}

变量如下所示:

"name": "sxp",
"sqlServerName": "[variables('liveName')]",
"sqlServerDevelopmentName": "[variables('developmentName')]",
"sxpDatabaseName": "[variables('name')]",
"cosmosContainerName": "products",
"cosmosThroughPut": "400",
"cosmosDevelopThroughPut": "400",

当我运行我的版本时,我得到这个错误(对于两个DocumentDb服务器):

{
    "status": "Failed",
    "error": {
        "code": "ResourceDeploymentFailure",
        "message": "The resource operation completed with terminal provisioning state 'Failed'.",
        "details": [
            {
                "code": "BadRequest",
                "message": "Message: {\"code\":\"BadRequest\",\"message\":\"Message: {\\\"partitionCount\\\":1}\\r\\nActivityId: b0751976-2076-4f29-93ab-b3d5849390b8, Request URI: /apps/0ccd856f-da7a-4ff9-a530-88ce0dbfd50c/services/b3350877-fd5e-4ea1-b6ee-41ecb9fb2540/partitions/14300278-223a-4614-afca-48f66e186695/replicas/132272757678585484p, RequestStats: , SDK: Microsoft.Azure.Documents.Common/2.9.2\"}, Request URI: /dbs, RequestStats: , SDK: Microsoft.Azure.Documents.Common/2.9.2, Microsoft.Azure.Documents.Common/2.9.2, Microsoft.Azure.Documents.Common/2.9.2, Microsoft.Azure.Documents.Common/2.9.2, Microsoft.Azure.Documents.Common/2.9.2, Microsoft.Azure.Documents.Common/2.9.2, Microsoft.Azure.Documents.Common/2.9.2, Microsoft.Azure.Documents.Common/2.9.2, Microsoft.Azure.Documents.Common/2.9.2"
            }
        ]
    }
}

这对我来说毫无意义。我试过用谷歌搜索它,但找不到任何错误的参考。奇怪的是,它创建了资源,并且这些资源是可用的,但部署说它失败了。

以前有人看过这个问题吗?

共有1个答案

诸葛品
2023-03-14

我已经弄清楚了。这与id属性有关。您必须有一个。如果您使用arm-ttk-master,它会告诉您不使用resourceId函数是无效的,但在cosmos数据库和容器的情况下,它是错误的......

所以,它应该是这样的:

{
  "type": "Microsoft.DocumentDB/databaseAccounts/apis/databases",
  "name": "[concat(variables('sqlServerDevelopmentName'), '/sql/', variables('name'))]",
  "apiVersion": "2016-03-31",
  "dependsOn": [
    "[resourceId('Microsoft.DocumentDB/databaseAccounts', variables('sqlServerDevelopmentName'))]"
  ],
  "properties": {
    "resource": {
      "id": "[variables('name')]"
    },
    "options": {
      "throughput": "[variables('cosmosDevelopThroughPut')]"
    }
  }
},
{
  "name": "[concat(variables('sqlServerName'), '/sql/', variables('name'), '/', variables('cosmosContainerName'))]",
  "type": "Microsoft.DocumentDb/databaseAccounts/apis/databases/containers",
  "apiVersion": "2016-03-31",
  "dependsOn": [
    "[resourceId('Microsoft.DocumentDB/databaseAccounts/apis/databases', variables('sqlServerName'), 'sql', variables('name'))]"
  ],
  "properties": {
    "resource": {
      "id": "[variables('cosmosContainerName')]",
      "partitionKey": {
        "paths": [
          "/categoryId"
        ],
        "kind": "Hash"
      },
      "indexingPolicy": {
        "indexingMode": "consistent",
        "includedPaths": [{
          "path": "/*"
        }]
      }
    }
  }
},

注意id属性:

"id": "[variables('cosmosContainerName')]",
 类似资料:
  • 我想使用arm模板在我的密钥库中创建秘密。但我得到以下错误 注意:密钥库已经创建,所以arm模板中不需要密钥库 谢谢

  • 我创建的密钥存储库位于另一个资源组中,我正在将逻辑应用程序部署到其他资源组中,在这些资源组中我引用了密钥值秘密,如下所示: 我正在使用CICD部署逻辑应用程序,但在发布定义中,我得到以下错误: KeyVaultParameterReferenceAuthorization失败:对象id为“648FA2CC-6CD1-49FA-A11A-AD6A276916CC”的客户端“648FA2CC-6CD1

  • 我有一个。NET解决方案,其中包含多个项目。我想在Azure运营模式中设置部署管道,但不确定如何做到这一点。我想有1个管道,部署以下项目: 主web应用程序- 我该如何设置?我选择了默认的“Azure应用程序服务部署”模板,但在部署任务中,我无法选择要部署的项目。包引用了,但这是一个zip文件,其中包含我的两个web项目的工件(此处缺少数据库DACPAC)。

  • 我在旧版本的C Cookbook中看到了这段代码,这让我很困惑。这似乎是编译,但我不知道为什么代码会这样写。 T()是什么意思?这是std::accumulate的init参数——开始求和的值。我编写了一个版本,其中我将double()替换为T()(以“硬连线”模板),然后它进行编译。double()是什么意思?

  • 我试图用PS和ARM来取代SQL Server逻辑服务器。我可以成功地在portal上创建具有贡献者权限的逻辑服务器,但不知道这里出了什么问题。 我在Windows上有PowerShell ISE。 错误:New-AzResourceGroupDeployment:17.35.18-error:code=InvalidTemplateDeployment;Message=模板部署失败,错误为:“模

  • null 我是不是漏了什么? 谢谢