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

            using var scope = _clientDiagnostics.CreateScope("SqlServerCollection.Get");
            scope.Start();
            try
            {
                var response = await _serversRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, serverName, expand, cancellationToken).ConfigureAwait(false);

                if (response.Value == null)
                {
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
                }
                return(Response.FromValue(new SqlServer(Parent, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }