public async virtual Task <Response <OutboundRule> > GetAsync(string outboundRuleName, CancellationToken cancellationToken = default)
        {
            if (outboundRuleName == null)
            {
                throw new ArgumentNullException(nameof(outboundRuleName));
            }

            using var scope = _clientDiagnostics.CreateScope("OutboundRuleCollection.Get");
            scope.Start();
            try
            {
                var response = await _loadBalancerOutboundRulesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, outboundRuleName, cancellationToken).ConfigureAwait(false);

                if (response.Value == null)
                {
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
                }
                return(Response.FromValue(new OutboundRule(Parent, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
예제 #2
0
        public virtual async Task <Response <OutboundRuleResource> > GetAsync(CancellationToken cancellationToken = default)
        {
            using var scope = _outboundRuleLoadBalancerOutboundRulesClientDiagnostics.CreateScope("OutboundRuleResource.Get");
            scope.Start();
            try
            {
                var response = await _outboundRuleLoadBalancerOutboundRulesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false);

                if (response.Value == null)
                {
                    throw new RequestFailedException(response.GetRawResponse());
                }
                return(Response.FromValue(new OutboundRuleResource(Client, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }