public async virtual Task <IpAllocationCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, string ipAllocationName, IpAllocationData parameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(ipAllocationName, nameof(ipAllocationName)); if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _ipAllocationClientDiagnostics.CreateScope("IpAllocationCollection.CreateOrUpdate"); scope.Start(); try { var response = await _ipAllocationRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, ipAllocationName, parameters, cancellationToken).ConfigureAwait(false); var operation = new IpAllocationCreateOrUpdateOperation(ArmClient, _ipAllocationClientDiagnostics, Pipeline, _ipAllocationRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, ipAllocationName, parameters).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <ArmOperation <IPAllocation> > CreateOrUpdateAsync(WaitUntil waitUntil, string ipAllocationName, IPAllocationData parameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(ipAllocationName, nameof(ipAllocationName)); Argument.AssertNotNull(parameters, nameof(parameters)); using var scope = _ipAllocationIpAllocationsClientDiagnostics.CreateScope("IPAllocationCollection.CreateOrUpdate"); scope.Start(); try { var response = await _ipAllocationIpAllocationsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, ipAllocationName, parameters, cancellationToken).ConfigureAwait(false); var operation = new NetworkArmOperation <IPAllocation>(new IPAllocationOperationSource(Client), _ipAllocationIpAllocationsClientDiagnostics, Pipeline, _ipAllocationIpAllocationsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, ipAllocationName, parameters).Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }