IDocumentClient.UpsertTriggerAsync メソッド

定義

オーバーロード

UpsertTriggerAsync(String, Trigger, RequestOptions)

Azure Cosmos DB サービスの非同期操作としてトリガーをアップサートします。

UpsertTriggerAsync(Uri, Trigger, RequestOptions)

Azure Cosmos DB サービスの非同期操作としてトリガーをアップサートします。

UpsertTriggerAsync(String, Trigger, RequestOptions)

Azure Cosmos DB サービスの非同期操作としてトリガーをアップサートします。

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Trigger>> UpsertTriggerAsync (string collectionLink, Microsoft.Azure.Documents.Trigger trigger, Microsoft.Azure.Documents.Client.RequestOptions options = default);
abstract member UpsertTriggerAsync : string * Microsoft.Azure.Documents.Trigger * Microsoft.Azure.Documents.Client.RequestOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Trigger>>
Public Function UpsertTriggerAsync (collectionLink As String, trigger As Trigger, Optional options As RequestOptions = Nothing) As Task(Of ResourceResponse(Of Trigger))

パラメーター

collectionLink
String

トリガーを DocumentCollection アップサートする のリンク。 例: dbs/db_rid/colls/col_rid/

trigger
Trigger

Triggerアップサートするオブジェクト。

options
RequestOptions

(省略可能)この要求の任意 RequestOptions

戻り値

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

例外

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

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

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

StatusCode例外の理由
400BadRequest - これは、指定された要求に問題が発生したことを意味します。 新しいトリガーに ID が指定されていないか、本文の形式が正しくない可能性があります。
403禁止 - 指定されたコレクションのトリガーのクォータに達しました。 このクォータを増やすには、サポートにお問い合わせください。
409競合 - 指定した ID と一致する ID が既に存在する を意味 Trigger します。
413RequestEntityTooLarge - アップサートしようとした本文が Trigger 大きすぎたことが意味されます。

//Upsert a trigger that validates the contents of a document as it is created and adds a 'timestamp' property if one was not found.
Trigger trig = await client.UpsertTriggerAsync(collectionLink, new Trigger
{
    Id = "ValidateDocuments",
    Body = @"function validate() {
                        var context = getContext();
                        var request = context.getRequest();                                                             
                        var documentToCreate = request.getBody();

                        // validate properties
                        if (!('timestamp' in documentToCreate)) {
                            var ts = new Date();
                            documentToCreate['timestamp'] = ts.getTime();
                        }

                        // update the document that will be created
                        request.setBody(documentToCreate);
                      }",
    TriggerType = TriggerType.Pre,
    TriggerOperation = TriggerOperation.Create
});

こちらもご覧ください

適用対象

UpsertTriggerAsync(Uri, Trigger, RequestOptions)

Azure Cosmos DB サービスの非同期操作としてトリガーをアップサートします。

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Trigger>> UpsertTriggerAsync (Uri documentCollectionUri, Microsoft.Azure.Documents.Trigger trigger, Microsoft.Azure.Documents.Client.RequestOptions options = default);
abstract member UpsertTriggerAsync : Uri * Microsoft.Azure.Documents.Trigger * Microsoft.Azure.Documents.Client.RequestOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Trigger>>
Public Function UpsertTriggerAsync (documentCollectionUri As Uri, trigger As Trigger, Optional options As RequestOptions = Nothing) As Task(Of ResourceResponse(Of Trigger))

パラメーター

documentCollectionUri
Uri

トリガーをアップサートするドキュメント コレクションの URI。

trigger
Trigger

Trigger オブジェクト。

options
RequestOptions

(省略可能) RequestOptions 要求の 。

戻り値

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

適用対象