Beispiel #1
0
        public virtual async Task <Response <SessionHostResource> > GetAsync(string sessionHostName, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(sessionHostName, nameof(sessionHostName));

            using var scope = _sessionHostClientDiagnostics.CreateScope("SessionHostCollection.Get");
            scope.Start();
            try
            {
                var response = await _sessionHostRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, sessionHostName, cancellationToken).ConfigureAwait(false);

                if (response.Value == null)
                {
                    throw new RequestFailedException(response.GetRawResponse());
                }
                return(Response.FromValue(new SessionHostResource(Client, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public async virtual Task <Response <SessionHost> > GetAsync(CancellationToken cancellationToken = default)
        {
            using var scope = _sessionHostClientDiagnostics.CreateScope("SessionHost.Get");
            scope.Start();
            try
            {
                var response = await _sessionHostRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false);

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