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

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

                if (response.Value == null)
                {
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
                }
                return(Response.FromValue(new Probe(Parent, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Ejemplo n.º 2
0
        public virtual async Task <Response <ProbeResource> > GetAsync(CancellationToken cancellationToken = default)
        {
            using var scope = _probeLoadBalancerProbesClientDiagnostics.CreateScope("ProbeResource.Get");
            scope.Start();
            try
            {
                var response = await _probeLoadBalancerProbesRestClient.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 ProbeResource(Client, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }