azure - 从 cosmos DB 中提取分区键

标签 azure azure-cosmosdb azure-cosmosdb-sqlapi

如何提取集合中所有分区键的列表?假设我有cosmos DB的收藏链接。

我正在尝试这样的事情:

foreach (var id in client.CreateDocumentQuery(UriFactory.CreateDocumentCollectionUri("db12", "coll12"),
    "SELECT DISTINCT c.Partitionkey FROM c", queryOptions))
            {
                Console.WriteLine("\tRead------------------- {0} from SQL", id);
            }

这给出了空结果。

最佳答案

您只需将Partitionkey修改为您的分区键的字段名称即可。

例如,我的分区键是 name,因此查询如下:

select distinct c.name from c

我的查询结果如下:

enter image description here

它还可以提取""undefined

希望对您有帮助。

关于azure - 从 cosmos DB 中提取分区键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50753870/

相关文章:

.net - Azure:Function App Cosmosdb触发本地开发

c# - 使用 Cosmos DB 配置 EF Core 以存储字符串的 ICollection

azure - Cosmos DB 分页提供倍增的页面记录

asp.net - Azure - Web 服务角色可以支持多少用户?

visual-studio - 无法评估扩展元数据的 'Cosmos.CRTCompat.dll'。异常消息: Bad IL format

azure - 通过 Windows Server 2012 R2 托管网页

azure - 如何禁用azure cosmos db连续备份

azure - 在 Docker 容器中连接 Cosmos Emulator DB

azure - 为什么在生产中使用 CreateDatabaseIfNotExistsAsync 和其他类似的方法?

azure - 关于Azure表设计