【问题标题】:Get Cosmosdb Container Collection items using powershell使用 powershell 获取 Cosmosdb Container Collection 项
【发布时间】:2020-04-14 14:45:37
【问题描述】:

团队,我在 Azure 门户中创建了新的 CosmosDB 帐户,其中包含一个包含集合项列表的容器。我可以在 power shell 脚本中访问容器详细信息。

如何使用 power shell 脚本使用分区键列出集合项或显示特定的集合项

Power shell 脚本:

  Get-AzResource -ResourceType "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers" -ApiVersion "2020-03-01" -ResourceGroupName "testRG" -Name "cosmosaccount1/database1/containercollection1"

【问题讨论】:

    标签: azure powershell azure-cosmosdb azure-powershell az


    【解决方案1】:

    您需要为此使用第三方模块之类的东西。 Azure 资源管理器不支持,因此您需要直接与 Cosmos DB 对话。

    https://github.com/PlagueHO/CosmosDB

    【讨论】:

      【解决方案2】:

      Cosmos DB 存储库有一组使用 Powershell 的示例:https://github.com/Azure/azure-cosmos-dotnet-v3/tree/master/Microsoft.Azure.Cosmos.Samples/Usage/PowerShellRestApi

      特别要阅读的项目:https://github.com/Azure/azure-cosmos-dotnet-v3/blob/master/Microsoft.Azure.Cosmos.Samples/Usage/PowerShellRestApi/PowerShellScripts/ReadItem.ps1

      他们都在使用 REST API 进行 REST 请求,在这种情况下,它是经过身份验证的 GEThttps://{databaseaccount}.documents.azure.com/dbs/{db-id}/colls/{coll-id}/docs/{id}(其中 databaseaccount 是您的帐户名,db- id 是你的数据库的 id,coll-id 是你的集合/容器的 id,id 是你的文档 id)。它还为分区键设置x-ms-documentdb-partitionkey 标头。

      【讨论】:

      • 我们有关于“如何使用 REST API 中的查询获取 Cosmos Db 文档”的任何参考链接。我正在尝试使用 Body 作为 JSON 来执行 POST 动词,以使用 sql 查询获取特定文档,但出现错误
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-06-15
      • 2022-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多