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?
func host start
in Azure Functions Core Tools ,as mentioned in this SO Thread :#67013922 , And please let me know if it works or if the same issue still happening. – Apocalyptic