public virtual Pageable <RoleInstanceResource> GetAll(InstanceViewTypes?expand = null, CancellationToken cancellationToken = default) { Page <RoleInstanceResource> FirstPageFunc(int?pageSizeHint) { using var scope = _roleInstanceCloudServiceRoleInstancesClientDiagnostics.CreateScope("RoleInstanceCollection.GetAll"); scope.Start(); try { var response = _roleInstanceCloudServiceRoleInstancesRestClient.List(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, cancellationToken: cancellationToken); return(Page.FromValues(response.Value.Value.Select(value => new RoleInstanceResource(Client, value)), response.Value.NextLink, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } } Page <RoleInstanceResource> NextPageFunc(string nextLink, int?pageSizeHint) { using var scope = _roleInstanceCloudServiceRoleInstancesClientDiagnostics.CreateScope("RoleInstanceCollection.GetAll"); scope.Start(); try { var response = _roleInstanceCloudServiceRoleInstancesRestClient.ListNextPage(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, cancellationToken: cancellationToken); return(Page.FromValues(response.Value.Value.Select(value => new RoleInstanceResource(Client, value)), response.Value.NextLink, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } } return(PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc)); }