Database.CreateContainerAsync メソッド

定義

オーバーロード

CreateContainerAsync(ContainerProperties, ThroughputProperties, RequestOptions, CancellationToken)

Azure Cosmos サービスで非同期操作としてコンテナーを作成します。

CreateContainerAsync(ContainerProperties, Nullable<Int32>, RequestOptions, CancellationToken)

Azure Cosmos サービスで非同期操作としてコンテナーを作成します。

CreateContainerAsync(String, String, Nullable<Int32>, RequestOptions, CancellationToken)

Azure Cosmos サービスで非同期操作としてコンテナーを作成します。

CreateContainerAsync(ContainerProperties, ThroughputProperties, RequestOptions, CancellationToken)

Azure Cosmos サービスで非同期操作としてコンテナーを作成します。

public abstract System.Threading.Tasks.Task<Microsoft.Azure.Cosmos.ContainerResponse> CreateContainerAsync (Microsoft.Azure.Cosmos.ContainerProperties containerProperties, Microsoft.Azure.Cosmos.ThroughputProperties throughputProperties, Microsoft.Azure.Cosmos.RequestOptions requestOptions = default, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateContainerAsync : Microsoft.Azure.Cosmos.ContainerProperties * Microsoft.Azure.Cosmos.ThroughputProperties * Microsoft.Azure.Cosmos.RequestOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Cosmos.ContainerResponse>
Public MustOverride Function CreateContainerAsync (containerProperties As ContainerProperties, throughputProperties As ThroughputProperties, Optional requestOptions As RequestOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ContainerResponse)

パラメーター

containerProperties
ContainerProperties

ContainerProperties オブジェクト。

throughputProperties
ThroughputProperties

(省略可能)Azure Cosmos DB サービスの 1 秒あたりの要求ユニット数の測定でコンテナーにプロビジョニングされるスループット。

requestOptions
RequestOptions

(省略可能)要求のオプション。

cancellationToken
CancellationToken

(省略可能) CancellationToken 要求の取り消しを表します。

戻り値

Task読み取りリソース レコードをContainerResponse含む をContainerPropertiesラップする を含む 。

例外

が設定されていない場合 containerProperties

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

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

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

ContainerProperties containerProperties = new ContainerProperties()
{
    Id = Guid.NewGuid().ToString(),
    PartitionKeyPath = "/pk",
    IndexingPolicy = new IndexingPolicy()
   {
        Automatic = false,
        IndexingMode = IndexingMode.Lazy,
   }
};

ContainerResponse response = await this.cosmosDatabase.CreateContainerAsync(
    containerProperties,
    ThroughputProperties.CreateAutoscaleThroughput(10000));

適用対象

CreateContainerAsync(ContainerProperties, Nullable<Int32>, RequestOptions, CancellationToken)

Azure Cosmos サービスで非同期操作としてコンテナーを作成します。

public abstract System.Threading.Tasks.Task<Microsoft.Azure.Cosmos.ContainerResponse> CreateContainerAsync (Microsoft.Azure.Cosmos.ContainerProperties containerProperties, int? throughput = default, Microsoft.Azure.Cosmos.RequestOptions requestOptions = default, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateContainerAsync : Microsoft.Azure.Cosmos.ContainerProperties * Nullable<int> * Microsoft.Azure.Cosmos.RequestOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Cosmos.ContainerResponse>
Public MustOverride Function CreateContainerAsync (containerProperties As ContainerProperties, Optional throughput As Nullable(Of Integer) = Nothing, Optional requestOptions As RequestOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ContainerResponse)

パラメーター

containerProperties
ContainerProperties

ContainerProperties オブジェクト。

throughput
Nullable<Int32>

(省略可能)Azure Cosmos DB サービスの 1 秒あたりの要求ユニット数の測定でコンテナーにプロビジョニングされるスループット。

requestOptions
RequestOptions

(省略可能)要求のオプション。

cancellationToken
CancellationToken

(省略可能) CancellationToken 要求の取り消しを表します。

戻り値

Task読み取りリソース レコードをContainerResponse含む をContainerPropertiesラップする を含む 。

例外

が設定されていない場合 containerProperties

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

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

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

ContainerProperties containerProperties = new ContainerProperties()
{
    Id = Guid.NewGuid().ToString(),
    PartitionKeyPath = "/pk",
    IndexingPolicy = new IndexingPolicy()
   {
        Automatic = false,
        IndexingMode = IndexingMode.Lazy,
   }
};

ContainerResponse response = await this.cosmosDatabase.CreateContainerAsync(containerProperties);

注釈

https://docs.microsoft.com/azure/cosmos-db/request-units プロビジョニングスループットの詳細については、

こちらもご覧ください

適用対象

CreateContainerAsync(String, String, Nullable<Int32>, RequestOptions, CancellationToken)

Azure Cosmos サービスで非同期操作としてコンテナーを作成します。

public abstract System.Threading.Tasks.Task<Microsoft.Azure.Cosmos.ContainerResponse> CreateContainerAsync (string id, string partitionKeyPath, int? throughput = default, Microsoft.Azure.Cosmos.RequestOptions requestOptions = default, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateContainerAsync : string * string * Nullable<int> * Microsoft.Azure.Cosmos.RequestOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Cosmos.ContainerResponse>
Public MustOverride Function CreateContainerAsync (id As String, partitionKeyPath As String, Optional throughput As Nullable(Of Integer) = Nothing, Optional requestOptions As RequestOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ContainerResponse)

パラメーター

id
String

Cosmos コンテナー ID

partitionKeyPath
String

パーティション キーへのパス。 例: /location

throughput
Nullable<Int32>

(省略可能)Azure Cosmos DB サービスの 1 秒あたりの要求ユニット数の測定でコンテナーにプロビジョニングされるスループット。

requestOptions
RequestOptions

(省略可能)要求のオプション。

cancellationToken
CancellationToken

(省略可能) CancellationToken 要求の取り消しを表します。

戻り値

Task読み取りリソース レコードをContainerResponse含む をContainerPropertiesラップする を含む 。

例外

が設定されていない場合 id

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

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

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

ContainerResponse response = await this.cosmosDatabase.CreateContainerAsync(Guid.NewGuid().ToString(), "/pk");

注釈

https://docs.microsoft.com/azure/cosmos-db/request-units プロビジョニングスループットの詳細については、

こちらもご覧ください

適用対象