本文介绍了如何通过命令行填充CosmosDB集合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Azure开发一组脚本,我想知道如何用az填充CosmosDB集合.

I am developing a set of Scripts for Azure and I would like to know how to populate a CosmosDB collection with az.

当前,我知道如何创建数据库和集合,但是如何初始化数据库?

Currently, I know how to create a Database and Collection but how to initialize the Database?

  az cosmosdb create \
    --resource-group $RESOURCE_GROUP \
    --name $COSMOS_DB_ACCOUNT
  az cosmosdb database create \
    --resource-group-name $RESOURCE_GROUP \
    --name $COSMOS_DB_ACCOUNT \
    --db-name $COSMOS_DB_NAME
  az cosmosdb collection create \
    --resource-group-name $RESOURCE_GROUP \
    --name $COSMOS_DB_ACCOUNT \
    --collection-name $COSMOS_DB_COLLECTION_NAME \
    --db-name $COSMOS_DB_NAME \
    --partition-key-path $COSMOS_DB_COLLECTION_PARTITION_KEY

在阅读文档时,我没有找到解决方法.

Reading the documentation, I didn´t see a solution.

推荐答案

az没有为Cosmos DB提供任何数据移动选项.

az doesn't provide any data-movement options for Cosmos DB.

对于SQL API,您要么需要创建自己的命令行工具,要么使用Cosmos DB提供的数据迁移工具(仅Windows,与az不同),该工具提供了命令行界面. .例如:

For the SQL API, you'll either need to create your own command-line tool, or use the Cosmos DB-supplied Data Migration Tool (Windows-only, unlike az), which provides a command-line interface. For example:

dt /s:JsonFile /s.Files:.\inputdata.json /t:DocumentDBBulk /t.ConnectionString:"AccountEndpoint=<name>;AccountKey=<key>;Database=<db>;" /t.Collection:<collname> /t.CollectionThroughput:<throughput>

它也支持MongoDB API,但是您也可以使用本机命令行工具,例如mongoimport.

This has support for the MongoDB API as well, but you can also use native command-line tools such as mongoimport.

这篇关于如何通过命令行填充CosmosDB集合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 17:33