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

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

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