次の方法で共有


DocumentClient.CreateDocumentCollectionAsync メソッド

定義

オーバーロード

CreateDocumentCollectionAsync(String, DocumentCollection, RequestOptions)

Azure Cosmos DB サービスの非同期操作としてコレクションを作成します。

CreateDocumentCollectionAsync(Uri, DocumentCollection, RequestOptions)

Azure Cosmos DB サービスの非同期操作としてコレクションを作成します。

CreateDocumentCollectionAsync(String, DocumentCollection, RequestOptions)

Azure Cosmos DB サービスの非同期操作としてコレクションを作成します。

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.DocumentCollection>> CreateDocumentCollectionAsync (string databaseLink, Microsoft.Azure.Documents.DocumentCollection documentCollection, Microsoft.Azure.Documents.Client.RequestOptions options = default);
abstract member CreateDocumentCollectionAsync : string * Microsoft.Azure.Documents.DocumentCollection * Microsoft.Azure.Documents.Client.RequestOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.DocumentCollection>>
override this.CreateDocumentCollectionAsync : string * Microsoft.Azure.Documents.DocumentCollection * Microsoft.Azure.Documents.Client.RequestOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.DocumentCollection>>
Public Function CreateDocumentCollectionAsync (databaseLink As String, documentCollection As DocumentCollection, Optional options As RequestOptions = Nothing) As Task(Of ResourceResponse(Of DocumentCollection))

パラメーター

databaseLink
String

コレクションを作成するデータベースのリンク。 例: dbs/db_rid/.

documentCollection
DocumentCollection

DocumentCollection オブジェクト。

options
RequestOptions

(省略可能) RequestOptions コレクションの作成時に指定する任意のオブジェクト。 例: RequestOptions.OfferThroughput = 400。

戻り値

非同期操作の DocumentCollection サービス応答を Task 表す オブジェクト内に含まれる 作成された 。

実装

例外

または documentCollectiondatabaseLink設定されていない場合。

非同期処理中に発生したエラーの統合を表します。 InnerExceptions 内を見て、実際の例外を見つけます。

この例外により、さまざまな種類のエラーがカプセル化される可能性があります。 特定のエラーを特定するには、常に StatusCode プロパティを参照してください。 コレクションを作成するときに取得できる一般的なコードは次のとおりです。

StatusCode例外の理由
400BadRequest - これは、指定された要求に問題が発生したことを意味します。 新しいコレクションに ID が指定されていない可能性があります。
403禁止 - これは、コレクションのクォータを超えようとしたことを意味します。 このクォータを増やすには、サポートにお問い合わせください。
409競合 - 指定した ID と一致する ID が既に存在する を意味 DocumentCollection します。

using (IDocumentClient client = new DocumentClient(new Uri("service endpoint"), "auth key"))
{
    //Create a new collection with an OfferThroughput set to 10000
    //Not passing in RequestOptions.OfferThroughput will result in a collection with the default OfferThroughput set.
    DocumentCollection coll = await client.CreateDocumentCollectionAsync(databaseLink,
        new DocumentCollection { Id = "My Collection" },
        new RequestOptions { OfferThroughput = 10000} );
}

こちらもご覧ください

適用対象

CreateDocumentCollectionAsync(Uri, DocumentCollection, RequestOptions)

Azure Cosmos DB サービスの非同期操作としてコレクションを作成します。

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.DocumentCollection>> CreateDocumentCollectionAsync (Uri databaseUri, Microsoft.Azure.Documents.DocumentCollection documentCollection, Microsoft.Azure.Documents.Client.RequestOptions options = default);
abstract member CreateDocumentCollectionAsync : Uri * Microsoft.Azure.Documents.DocumentCollection * Microsoft.Azure.Documents.Client.RequestOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.DocumentCollection>>
override this.CreateDocumentCollectionAsync : Uri * Microsoft.Azure.Documents.DocumentCollection * Microsoft.Azure.Documents.Client.RequestOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.DocumentCollection>>
Public Function CreateDocumentCollectionAsync (databaseUri As Uri, documentCollection As DocumentCollection, Optional options As RequestOptions = Nothing) As Task(Of ResourceResponse(Of DocumentCollection))

パラメーター

databaseUri
Uri

コレクションを作成するデータベースの URI。

documentCollection
DocumentCollection

Microsoft.Azure.Documents.DocumentCollection オブジェクト。

options
RequestOptions

要求の要求オプション。

戻り値

非同期操作のサービス応答を表すタスク オブジェクト。

実装

適用対象