예제 #1
0
 public virtual ArmOperation <KeyValueResource> Update(WaitUntil waitUntil, KeyValueData data = null, CancellationToken cancellationToken = default)
 {
     using var scope = _keyValueClientDiagnostics.CreateScope("KeyValueResource.Update");
     scope.Start();
     try
     {
         var response  = _keyValueRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken);
         var operation = new AppConfigurationArmOperation <KeyValueResource>(Response.FromValue(new KeyValueResource(Client, response), response.GetRawResponse()));
         if (waitUntil == WaitUntil.Completed)
         {
             operation.WaitForCompletion(cancellationToken);
         }
         return(operation);
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }
예제 #2
0
 internal KeyValueResource(ArmClient client, KeyValueData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
        public virtual async Task <ArmOperation <KeyValueResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string keyValueName, KeyValueData data = null, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(keyValueName, nameof(keyValueName));

            using var scope = _keyValueClientDiagnostics.CreateScope("KeyValueCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _keyValueRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyValueName, data, cancellationToken).ConfigureAwait(false);

                var operation = new AppConfigurationArmOperation <KeyValueResource>(Response.FromValue(new KeyValueResource(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }