public async virtual Task <Response <FirewallRule> > GetAsync(string firewallRuleName, CancellationToken cancellationToken = default) { if (firewallRuleName == null) { throw new ArgumentNullException(nameof(firewallRuleName)); } using var scope = _clientDiagnostics.CreateScope("FirewallRuleCollection.Get"); scope.Start(); try { var response = await _firewallRulesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, firewallRuleName, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); } return(Response.FromValue(new FirewallRule(Parent, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <Response <FirewallRuleResource> > GetAsync(CancellationToken cancellationToken = default) { using var scope = _firewallRuleClientDiagnostics.CreateScope("FirewallRuleResource.Get"); scope.Start(); try { var response = await _firewallRuleRestClient.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 FirewallRuleResource(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }