public async virtual Task <VpnGatewayCreateOrUpdateOperation> CreateOrUpdateAsync(string gatewayName, VpnGatewayData vpnGatewayParameters, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (gatewayName == null)
            {
                throw new ArgumentNullException(nameof(gatewayName));
            }
            if (vpnGatewayParameters == null)
            {
                throw new ArgumentNullException(nameof(vpnGatewayParameters));
            }

            using var scope = _clientDiagnostics.CreateScope("VpnGatewayContainer.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _restClient.CreateOrUpdateAsync(Id.ResourceGroupName, gatewayName, vpnGatewayParameters, cancellationToken).ConfigureAwait(false);

                var operation = new VpnGatewayCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _restClient.CreateCreateOrUpdateRequest(Id.ResourceGroupName, gatewayName, vpnGatewayParameters).Request, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemplo n.º 2
0
        public virtual VpnGatewayCreateOrUpdateOperation CreateOrUpdate(bool waitForCompletion, string gatewayName, VpnGatewayData vpnGatewayParameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(gatewayName, nameof(gatewayName));
            if (vpnGatewayParameters == null)
            {
                throw new ArgumentNullException(nameof(vpnGatewayParameters));
            }

            using var scope = _vpnGatewayClientDiagnostics.CreateScope("VpnGatewayCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _vpnGatewayRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, gatewayName, vpnGatewayParameters, cancellationToken);
                var operation = new VpnGatewayCreateOrUpdateOperation(ArmClient, _vpnGatewayClientDiagnostics, Pipeline, _vpnGatewayRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, gatewayName, vpnGatewayParameters).Request, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }