コード例 #1
0
        public override Task <TriggerResponse> ReplaceTriggerAsync(
            CosmosTriggerProperties triggerSettings,
            RequestOptions requestOptions       = null,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            if (triggerSettings == null)
            {
                throw new ArgumentNullException(nameof(triggerSettings));
            }

            if (string.IsNullOrEmpty(triggerSettings.Id))
            {
                throw new ArgumentNullException(nameof(triggerSettings.Id));
            }

            if (string.IsNullOrEmpty(triggerSettings.Body))
            {
                throw new ArgumentNullException(nameof(triggerSettings.Body));
            }

            return(this.ProcessTriggerOperationAsync(
                       id: triggerSettings.Id,
                       operationType: OperationType.Replace,
                       streamPayload: CosmosResource.ToStream(triggerSettings),
                       requestOptions: requestOptions,
                       cancellationToken: cancellationToken));
        }
コード例 #2
0
 /// <summary>
 /// Replaces a <see cref="CosmosTriggerProperties"/> in the Azure Cosmos service as an asynchronous operation.
 /// </summary>
 /// <param name="triggerSettings">The <see cref="CosmosTriggerProperties"/> object.</param>
 /// <param name="requestOptions">(Optional) The options for the trigger request <see cref="RequestOptions"/></param>
 /// <param name="cancellationToken">(Optional) <see cref="CancellationToken"/> representing request cancellation.</param>
 /// <returns>
 /// A <see cref="Task"/> containing a <see cref="TriggerResponse"/> which wraps a <see cref="CosmosTriggerProperties"/> containing the updated resource record.
 /// </returns>
 /// <exception cref="ArgumentNullException">If <paramref name="triggerSettings"/> is not set.</exception>
 /// <example>
 /// This examples replaces an existing trigger.
 /// <code language="c#">
 /// <![CDATA[
 /// //Updated settings
 /// CosmosTriggerSettings settings = new CosmosTriggerSettings
 /// {
 ///     Id = "testTriggerId",
 ///     Body = @"function AddTax() {
 ///         var item = getContext().getRequest().getBody();
 ///
 ///         // Validate/calculate the tax.
 ///         item.tax = item.cost* .15;
 ///
 ///         // Update the request -- this is what is going to be inserted.
 ///         getContext().getRequest().setBody(item);
 ///     }",
 ///     TriggerOperation = TriggerOperation.All,
 ///     TriggerType = TriggerType.Post
 /// };
 ///
 /// CosmosScripts scripts = this.container.GetScripts();
 /// TriggerResponse response = await scripts.ReplaceTriggerAsync(CosmosTriggerSettings);
 /// ]]>
 /// </code>
 /// </example>
 public abstract Task <TriggerResponse> ReplaceTriggerAsync(
     CosmosTriggerProperties triggerSettings,
     RequestOptions requestOptions       = null,
     CancellationToken cancellationToken = default(CancellationToken));