コード例 #1
0
        public virtual TemplateSpecCreateOrUpdateOperation CreateOrUpdate(string templateSpecName, TemplateSpecData templateSpec, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (templateSpecName == null)
            {
                throw new ArgumentNullException(nameof(templateSpecName));
            }
            if (templateSpec == null)
            {
                throw new ArgumentNullException(nameof(templateSpec));
            }

            using var scope = _clientDiagnostics.CreateScope("TemplateSpecCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _templateSpecsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, templateSpecName, templateSpec, cancellationToken);
                var operation = new TemplateSpecCreateOrUpdateOperation(Parent, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
コード例 #2
0
        public virtual ArmOperation <TemplateSpecResource> CreateOrUpdate(WaitUntil waitUntil, string templateSpecName, TemplateSpecData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(templateSpecName, nameof(templateSpecName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _templateSpecClientDiagnostics.CreateScope("TemplateSpecCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _templateSpecRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, templateSpecName, data, cancellationToken);
                var operation = new ResourcesArmOperation <TemplateSpecResource>(Response.FromValue(new TemplateSpecResource(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }