public async virtual Task <Response <SshPublicKey> > GetAsync(string sshPublicKeyName, CancellationToken cancellationToken = default) { if (sshPublicKeyName == null) { throw new ArgumentNullException(nameof(sshPublicKeyName)); } using var scope = _clientDiagnostics.CreateScope("SshPublicKeyCollection.Get"); scope.Start(); try { var response = await _sshPublicKeysRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, sshPublicKeyName, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); } return(Response.FromValue(new SshPublicKey(this, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <Response <SshPublicKey> > GetAsync(CancellationToken cancellationToken = default) { using var scope = _sshPublicKeyClientDiagnostics.CreateScope("SshPublicKey.Get"); scope.Start(); try { var response = await _sshPublicKeyRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw await _sshPublicKeyClientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); } return(Response.FromValue(new SshPublicKey(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }