Example #1
0
        public async virtual Task <Response <ServerKey> > GetAsync(string keyName, CancellationToken cancellationToken = default)
        {
            if (keyName == null)
            {
                throw new ArgumentNullException(nameof(keyName));
            }

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

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