public async virtual Task <Response <NetworkSecurityGroup> > GetAsync(string networkSecurityGroupName, string expand = null, CancellationToken cancellationToken = default) { if (networkSecurityGroupName == null) { throw new ArgumentNullException(nameof(networkSecurityGroupName)); } using var scope = _clientDiagnostics.CreateScope("NetworkSecurityGroupCollection.Get"); scope.Start(); try { var response = await _networkSecurityGroupsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, networkSecurityGroupName, expand, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); } return(Response.FromValue(new NetworkSecurityGroup(Parent, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <Response <NetworkSecurityGroupResource> > GetAsync(string expand = null, CancellationToken cancellationToken = default) { using var scope = _networkSecurityGroupClientDiagnostics.CreateScope("NetworkSecurityGroupResource.Get"); scope.Start(); try { var response = await _networkSecurityGroupRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw new RequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new NetworkSecurityGroupResource(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }