为什么设置CosmosDB吞吐量设置会导致“系统中不存在具有指定ID的实体”?

问题描述 投票:0回答:1

[当尝试部署具有2个集合(“ MyCollection1”,“ MyCollection2”)的CosmosDB实例时,我一直收到错误消息:

未找到:具有指定标识的实体在系统中不存在

因此,我继续在自定义ARM模板中搜索“ resourceId”(请参见下文),但找不到错误原因。

我不明白,为什么管道至少不为我打印行号?

pipeline screenshot

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "accountName": {
            "defaultValue": "my-cosmosdb",
            "type": "String"
        }
    },
    "variables": {
        "resourceName": "[concat(resourceGroup().name, '-', parameters('accountName'))]",
        "resourceId": "[resourceId('Microsoft.DocumentDB/databaseAccounts', variables('resourceName'))]",
        "apiVersion": "[providers('Microsoft.DocumentDB', 'databaseAccounts').apiVersions[0]]"
    },
    "outputs": {
        "CosmosDbConnectionString": {
            "type": "string",
            "value": "[concat('AccountEndpoint=https://', variables('resourceName'), '.documents.azure.com:443/;AccountKey=', listKeys(variables('resourceId'), variables('apiVersion')).primaryMasterKey, ';')]"
        },
        "DatabaseName": {
            "type": "string",
            "value": "MyDB"
        },
        "CollectionName1": {
            "type": "string",
            "value": "MyCollection1"
        },
        "CollectionName2": {
            "type": "string",
            "value": "MyCollection2"
        }
    },
    "resources": [
        {
            "type": "Microsoft.DocumentDB/databaseAccounts",
            "apiVersion": "2020-03-01",
            "name": "[variables('resourceName')]",
            "location": "[resourceGroup().location]",
            "tags": {
                "defaultExperience": "DocumentDB"
            },
            "kind": "GlobalDocumentDB",
            "properties": {
                "publicNetworkAccess": "Enabled",
                "enableAutomaticFailover": false,
                "enableMultipleWriteLocations": false,
                "isVirtualNetworkFilterEnabled": false,
                "virtualNetworkRules": [],
                "disableKeyBasedMetadataWriteAccess": false,
                "databaseAccountOfferType": "Standard",
                "consistencyPolicy": {
                    "defaultConsistencyLevel": "Session",
                    "maxIntervalInSeconds": 5,
                    "maxStalenessPrefix": 100
                },
                "locations": [
                    {
                        "locationName": "[resourceGroup().location]",
                        "provisioningState": "Succeeded",
                        "failoverPriority": 0,
                        "isZoneRedundant": false
                    }
                ],
                "capabilities": []
            }
        },
        {
            "type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases",
            "apiVersion": "2020-03-01",
            "name": "[concat(variables('resourceName'), '/MyDB')]",
            "dependsOn": [
                "[resourceId('Microsoft.DocumentDB/databaseAccounts', variables('resourceName'))]"
            ],
            "properties": {
                "resource": {
                    "id": "MyDB"
                },
                "options": {}
            }
        },
        {
            "type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers",
            "apiVersion": "2020-03-01",
            "name": "[concat(variables('resourceName'), '/MyDB/MyCollection1')]",
            "dependsOn": [
                "[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', variables('resourceName'), 'MyDB')]",
                "[resourceId('Microsoft.DocumentDB/databaseAccounts', variables('resourceName'))]"
            ],
            "properties": {
                "resource": {
                    "id": "MyCollection1",
                    "indexingPolicy": {
                        "indexingMode": "consistent",
                        "automatic": true,
                        "includedPaths": [
                            {
                                "path": "/*"
                            }
                        ],
                        "excludedPaths": [
                            {
                                "path": "/\"_etag\"/?"
                            }
                        ]
                    },
                    "partitionKey": {
                        "paths": [
                            "/partitionKey"
                        ],
                        "kind": "Hash"
                    },
                    "uniqueKeyPolicy": {
                        "uniqueKeys": []
                    },
                    "conflictResolutionPolicy": {
                        "mode": "LastWriterWins",
                        "conflictResolutionPath": "/_ts"
                    }
                },
                "options": {}
            }
        },
        {
            "type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers",
            "apiVersion": "2020-03-01",
            "name": "[concat(variables('resourceName'), '/MyDB/MyCollection2')]",
            "dependsOn": [
                "[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', variables('resourceName'), 'MyDB')]",
                "[resourceId('Microsoft.DocumentDB/databaseAccounts', variables('resourceName'))]"
            ],
            "properties": {
                "resource": {
                    "id": "MyCollection2",
                    "indexingPolicy": {
                        "indexingMode": "consistent",
                        "automatic": true,
                        "includedPaths": [
                            {
                                "path": "/*"
                            }
                        ],
                        "excludedPaths": [
                            {
                                "path": "/\"_etag\"/?"
                            }
                        ]
                    },
                    "partitionKey": {
                        "paths": [
                            "/partitionKey"
                        ],
                        "kind": "Hash"
                    },
                    "uniqueKeyPolicy": {
                        "uniqueKeys": []
                    },
                    "conflictResolutionPolicy": {
                        "mode": "LastWriterWins",
                        "conflictResolutionPath": "/_ts"
                    }
                },
                "options": {}
            }
        },
        {
            "type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/throughputSettings",
            "apiVersion": "2020-03-01",
            "name": "[concat(variables('resourceName'), '/MyDB/default')]",
            "dependsOn": [
                "[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', variables('resourceName'), 'MyDB')]",
                "[resourceId('Microsoft.DocumentDB/databaseAccounts', variables('resourceName'))]"
            ],
            "properties": {
                "resource": {
                    "throughput": 400
                }
            }
        }
    ]
}

UPDATE:

我已经删除了创建集合的部分,并且错误仍然存​​在。

UPDATE 2:

以下部分似乎引起了错误,但是为什么呢?

{
    "type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/throughputSettings",
    "apiVersion": "2020-03-01",
    "name": "[concat(variables('resourceName'), '/MyDB/default')]",
    "dependsOn": [
        "[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', variables('resourceName'), 'MyDB')]",
        "[resourceId('Microsoft.DocumentDB/databaseAccounts', variables('resourceName'))]"
    ],
    "properties": {
        "resource": {
            "throughput": 400
        }
    }
}

dependsOn"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', variables('resourceName'), 'MyDB')]怎么了?

UPDATE 3:

尝试手动部署上面列出的完整ARM模板会导致:

screenshot throughput error

screenshot error

azure azure-cosmosdb azure-resource-manager arm-template azure-template
1个回答
1
投票
尝试在数据库的选项中设置吞吐量。

{ "type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases", "apiVersion": "2020-03-01", "name": "[concat(variables('resourceName'), '/MyDB')]", "dependsOn": [ "[resourceId('Microsoft.DocumentDB/databaseAccounts', variables('resourceName'))]" ], "properties": { "resource": { "id": "MyDB" }, "options": { "throughput": "[parameters('throughput')]" } } },

顺便说一句,您可以使用很多示例从Cosmos DB templates开始
© www.soinside.com 2019 - 2024. All rights reserved.