public async virtual Task <TemplateSpecCreateOrUpdateOperation> CreateOrUpdateAsync(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 = await _templateSpecsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, templateSpecName, templateSpec, cancellationToken).ConfigureAwait(false); var operation = new TemplateSpecCreateOrUpdateOperation(Parent, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <ArmOperation <TemplateSpecResource> > CreateOrUpdateAsync(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 = await _templateSpecRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, templateSpecName, data, cancellationToken).ConfigureAwait(false); var operation = new ResourcesArmOperation <TemplateSpecResource>(Response.FromValue(new TemplateSpecResource(Client, response), response.GetRawResponse())); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }