public virtual async Task <Response <Secret> > GetAsync(CancellationToken cancellationToken = default) { using var scope = _secretClientDiagnostics.CreateScope("Secret.Get"); scope.Start(); try { var response = await _secretRestClient.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 Secret(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <Response <Secret> > GetAsync(string secretName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(secretName, nameof(secretName)); using var scope = _secretClientDiagnostics.CreateScope("SecretCollection.Get"); scope.Start(); try { var response = await _secretRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, secretName, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw await _secretClientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); } return(Response.FromValue(new Secret(ArmClient, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }