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