public async virtual Task <Response <RoleInstance> > GetAsync(string roleInstanceName, InstanceViewTypes?expand = null, CancellationToken cancellationToken = default) { if (roleInstanceName == null) { throw new ArgumentNullException(nameof(roleInstanceName)); } using var scope = _clientDiagnostics.CreateScope("RoleInstanceCollection.Get"); scope.Start(); try { var response = await _cloudServiceRoleInstancesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, roleInstanceName, expand, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); } return(Response.FromValue(new RoleInstance(Parent, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <Response <CloudServiceRoleInstanceResource> > GetAsync(InstanceViewTypes?expand = null, CancellationToken cancellationToken = default) { using var scope = _cloudServiceRoleInstanceClientDiagnostics.CreateScope("CloudServiceRoleInstanceResource.Get"); scope.Start(); try { var response = await _cloudServiceRoleInstanceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, expand, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw new RequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new CloudServiceRoleInstanceResource(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }