public async virtual Task <ArmOperation <CdnOrigin> > CreateOrUpdateAsync(bool waitForCompletion, string originName, CdnOriginData origin, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(originName, nameof(originName)); if (origin == null) { throw new ArgumentNullException(nameof(origin)); } using var scope = _cdnOriginClientDiagnostics.CreateScope("CdnOriginCollection.CreateOrUpdate"); scope.Start(); try { var response = await _cdnOriginRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, originName, origin, cancellationToken).ConfigureAwait(false); var operation = new CdnArmOperation <CdnOrigin>(new CdnOriginOperationSource(Client), _cdnOriginClientDiagnostics, Pipeline, _cdnOriginRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, originName, origin).Request, response, OperationFinalStateVia.Location); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <CdnOriginCreateOperation> CreateOrUpdateAsync(string originName, CdnOriginData origin, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (originName == null) { throw new ArgumentNullException(nameof(originName)); } if (origin == null) { throw new ArgumentNullException(nameof(origin)); } using var scope = _clientDiagnostics.CreateScope("CdnOriginCollection.CreateOrUpdate"); scope.Start(); try { var response = await _cdnOriginsRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, originName, origin, cancellationToken).ConfigureAwait(false); var operation = new CdnOriginCreateOperation(Parent, _clientDiagnostics, Pipeline, _cdnOriginsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, originName, origin).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }