Solution: CS1061: 'AsyncPageable<GenericResourceExpanded>' does not contain a definition for 'GetAwaiter'

I’ve been coding in .NET for a very-long-time, but this tripped me up.

Run the following code:

var resources = await client.Resources.ListByResourceGroupAsync(resourceGroupName);
foreach (var resource in resources)
&#123;
    Console.WriteLine(resource.Name);
&#125;

And you get this:

error CS1061: 'AsyncPageable<GenericResourceExpanded>' does not contain a definition for 'GetAwaiter' 
and no accessible extension method 'GetAwaiter' accepting a first argument of type 'AsyncPageable<GenericResourceExpanded>' could be found 
(are you missing a using directive or an assembly reference?)

I thought I was doing everything right, awaiting an “Async” method. But it turns out with IAsyncEnumerable you await the result of the call like so:

var resources = client.Resources.ListByResourceGroupAsync(resourceGroupName);
await foreach (var resource in resources)
&#123;
    Console.WriteLine(resource.Name);
&#125;

Notice the await foreach?

I hope that helps.
Jon