Using .NET5 Azure function in Visual Studio 2019, I am getting the below exception from Program.cs:
System.InvalidOperationException: The gRPC channel URI 'http://0' could not be parsed
My Program.cs
is below:
public static void Main()
{
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.ConfigureServices(services =>
{
services.AddSingleton<IConfiguration>(data =>
{
var result = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("AppSettings.json", false, true)
.AddJsonFile($"AppSettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production"}.json", true)
.AddEnvironmentVariables()
.Build();
return result;
});
services.AddSingleton<IServiceProvider, ServiceProvider>();
})
.UseDefaultServiceProvider(options => options.ValidateScopes = false)
.Build();
host.Run();
}
The exception is being thrown from host.Run()
in Debug mode. Any clue?
For me it was occurring in Rider. The issue was that I was running the Function App as a .Net Project instead of as Azure Functions host.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With