예제 #1
0
 /// <summary> This operation allows adding a name to the list of predefined tag names for the given subscription. A tag name can have a maximum of 512 characters and is case-insensitive. Tag names cannot have the following prefixes which are reserved for Azure use: &apos;microsoft&apos;, &apos;azure&apos;, &apos;windows&apos;. </summary>
 /// <param name="tagName"> The name of the tag to create. </param>
 /// <param name="waitForCompletion"> Waits for the completion of the long running operations. </param>
 /// <param name="cancellationToken"> The cancellation token to use. </param>
 public virtual PredefinedTagCreateOrUpdateOperation CreateOrUpdate(string tagName, bool waitForCompletion = true, CancellationToken cancellationToken = default)
 {
     using var scope = Diagnostics.CreateScope("PredefinedTagContainer.CreateOrUpdate");
     scope.Start();
     try
     {
         var originalResponse = RestClient.CreateOrUpdate(tagName, cancellationToken);
         var operation        = new PredefinedTagCreateOrUpdateOperation(this, originalResponse);
         if (waitForCompletion)
         {
             operation.WaitForCompletion(cancellationToken);
         }
         return(operation);
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }
        /// <summary> This operation allows adding a name to the list of predefined tag names for the given subscription. A tag name can have a maximum of 512 characters and is case-insensitive. Tag names cannot have the following prefixes which are reserved for Azure use: &apos;microsoft&apos;, &apos;azure&apos;, &apos;windows&apos;. </summary>
        /// <param name="tagName"> The name of the tag to create. </param>
        /// <param name="waitForCompletion"> Waits for the completion of the long running operations. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        public virtual async Task <PredefinedTagCreateOrUpdateOperation> CreateOrUpdateAsync(string tagName, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            using var scope = Diagnostics.CreateScope("PredefinedTagCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var originalResponse = await RestClient.CreateOrUpdateAsync(tagName, cancellationToken).ConfigureAwait(false);

                var operation = new PredefinedTagCreateOrUpdateOperation(this, originalResponse);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }