You need the Microsoft.Extensions.Configuration namespace in scope to get that extension method. Either fully qualify it, or add this to the top of your file:
using Microsoft.Extensions.Configuration;
You also will need the NuGet reference Microsoft.Extensions.Configuration.EnvironmentVariables.