public virtual AsyncPageable <DataCollectionRuleAssociationResource> GetDataCollectionRuleAssociationsByRuleAsync(CancellationToken cancellationToken = default) { async Task <Page <DataCollectionRuleAssociationResource> > FirstPageFunc(int?pageSizeHint) { using var scope = _dataCollectionRuleAssociationClientDiagnostics.CreateScope("DataCollectionRuleResource.GetDataCollectionRuleAssociationsByRule"); scope.Start(); try { var response = await _dataCollectionRuleAssociationRestClient.ListByRuleAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken : cancellationToken).ConfigureAwait(false); return(Page.FromValues(response.Value.Value.Select(value => new DataCollectionRuleAssociationResource(Client, value)), response.Value.NextLink, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } } async Task <Page <DataCollectionRuleAssociationResource> > NextPageFunc(string nextLink, int?pageSizeHint) { using var scope = _dataCollectionRuleAssociationClientDiagnostics.CreateScope("DataCollectionRuleResource.GetDataCollectionRuleAssociationsByRule"); scope.Start(); try { var response = await _dataCollectionRuleAssociationRestClient.ListByRuleNextPageAsync(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken : cancellationToken).ConfigureAwait(false); return(Page.FromValues(response.Value.Value.Select(value => new DataCollectionRuleAssociationResource(Client, value)), response.Value.NextLink, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } } return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc)); }