public virtual AsyncPageable <ManagementLockResource> GetAllAsync(string filter = null, CancellationToken cancellationToken = default) { async Task <Page <ManagementLockResource> > FirstPageFunc(int?pageSizeHint) { using var scope = _managementLockClientDiagnostics.CreateScope("ManagementLockCollection.GetAll"); scope.Start(); try { var response = await _managementLockRestClient.ListByScopeAsync(Id, filter, cancellationToken : cancellationToken).ConfigureAwait(false); return(Page.FromValues(response.Value.Value.Select(value => new ManagementLockResource(Client, value)), response.Value.NextLink, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } } async Task <Page <ManagementLockResource> > NextPageFunc(string nextLink, int?pageSizeHint) { using var scope = _managementLockClientDiagnostics.CreateScope("ManagementLockCollection.GetAll"); scope.Start(); try { var response = await _managementLockRestClient.ListByScopeNextPageAsync(nextLink, Id, filter, cancellationToken : cancellationToken).ConfigureAwait(false); return(Page.FromValues(response.Value.Value.Select(value => new ManagementLockResource(Client, value)), response.Value.NextLink, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } } return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc)); }