此错误是由于往CosmosDB数据库批量插入数据时出现计算内部错误所导致的。在这种情况下,应检查以下事项:
示例代码:
CosmosClient client = new CosmosClient(endpointUrl, primaryKey); Database database = await client.CreateDatabaseIfNotExistsAsync(databaseId); Container container = await database.CreateContainerAsync(containerId, partitionKey);
示例代码:
public class MyData { public string Id { get; set; } public string Name { get; set; } public int Age { get; set; } }
List
示例代码:
ContainerProperties containerProperties = await container.ReadContainerAsync(); string partitionKeyPath = containerProperties.PartitionKeyPath;
foreach (MyData data in dataList)
{
string partitionKeyValue = data.GetType().GetProperty(partitionKeyPath.Substring(1)).GetValue(data, null)?.ToString();
ItemResponse
如果上述方法无法解决问题,请联系CosmosDB支持团队以获得更进一步的帮助。
上一篇:AzureCosmosDbAutoscale计费的最大RU每小时与RU利用率不相符
下一篇:AzureCosmosDb的参数化查询抛出“Invalidquery.SpecifiedparameterizedqueryJSONismalformed.”错误。