azure-functions-core-tools icon indicating copy to clipboard operation
azure-functions-core-tools copied to clipboard

func init --docker creates a project that cannot run in docker?

Open eholman opened this issue 5 months ago • 0 comments

Version

Latest stable 4.0.7317

Description

I choose to generate an isolated c# project and then I try to run the dockerfile (via Jetbrains Rider).

It first pulls the image and then it tries to run the project but it crashes:

2025-06-19T20:39:34.223575650Z Unhandled exception. System.InvalidOperationException: Configuration is missing the 'HostEndpoint' information. Please ensure an entry with the key 'Functions:Worker:HostEndpoint' is present in your configuration.
2025-06-19T20:39:34.223630290Z    at Microsoft.Extensions.DependencyInjection.GrpcServiceCollectionExtensions.GetFunctionsHostGrpcUri(IConfiguration configuration) in D:\a\_work\1\s\src\DotNetWorker.Grpc\GrpcServiceCollectionExtensions.cs:line 83
2025-06-19T20:39:34.223636094Z    at Microsoft.Extensions.DependencyInjection.GrpcServiceCollectionExtensions.GrpcWorkerStartupOptionsSetup.Configure(GrpcWorkerStartupOptions options) in D:\a\_work\1\s\src\DotNetWorker.Grpc\GrpcServiceCollectionExtensions.cs:line 98
2025-06-19T20:39:34.223637995Z    at Microsoft.Extensions.Options.OptionsFactory`1.Create(String name)
2025-06-19T20:39:34.223639296Z    at Microsoft.Extensions.Options.UnnamedOptionsManager`1.get_Value()
2025-06-19T20:39:34.223640597Z    at Microsoft.Azure.Functions.Worker.Grpc.GrpcWorkerClientFactory..ctor(GrpcHostChannel outputChannel, IOptions`1 startupOptions) in D:\a\_work\1\s\src\DotNetWorker.Grpc\GrpcWorkerClientFactory.cs:line 29
2025-06-19T20:39:34.223642198Z    at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
2025-06-19T20:39:34.223643499Z    at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
2025-06-19T20:39:34.223645000Z    at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
2025-06-19T20:39:34.223646502Z    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
2025-06-19T20:39:34.223647803Z    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
2025-06-19T20:39:34.223649204Z    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
2025-06-19T20:39:34.223651005Z    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
2025-06-19T20:39:34.223654407Z    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
2025-06-19T20:39:34.223657009Z    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
2025-06-19T20:39:34.223660112Z    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
2025-06-19T20:39:34.223663414Z    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
2025-06-19T20:39:34.223665916Z    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
2025-06-19T20:39:34.223675823Z    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
2025-06-19T20:39:34.223678525Z    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
2025-06-19T20:39:34.223680326Z    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitIEnumerable(IEnumerableCallSite enumerableCallSite, RuntimeResolverContext context)
2025-06-19T20:39:34.223682228Z    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
2025-06-19T20:39:34.223684029Z    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
2025-06-19T20:39:34.223685830Z    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
2025-06-19T20:39:34.223687832Z    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
2025-06-19T20:39:34.223705245Z    at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(ServiceIdentifier serviceIdentifier)
2025-06-19T20:39:34.223714852Z    at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
2025-06-19T20:39:34.223719355Z    at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope)
2025-06-19T20:39:34.223722057Z    at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
2025-06-19T20:39:34.223724459Z    at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
2025-06-19T20:39:34.223726860Z    at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
2025-06-19T20:39:34.223730063Z    at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
2025-06-19T20:39:34.223733165Z    at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
2025-06-19T20:39:34.223735367Z    at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
2025-06-19T20:39:34.223737568Z    at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
2025-06-19T20:39:34.223739770Z    at Program.<Main>$(String[] args) in B:\sources\test\myfunc\Program.cs:line 14

When I add the configuration to set a HostEndPoint (e.g. http://127.0.0.1:8702) it throws the next exception.

2025-06-19T20:36:43.700605106Z Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'value')
2025-06-19T20:36:43.700745184Z    at Google.Protobuf.ProtoPreconditions.CheckNotNull[T](T value, String name)
2025-06-19T20:36:43.700753471Z    at Microsoft.Azure.Functions.Worker.Grpc.Messages.StartStream.set_WorkerId(String value) in D:\a\_work\1\s\src\DotNetWorker.Grpc\obj\Release\net8.0\FunctionRpc.cs:line 2055
2025-06-19T20:36:43.700757664Z    at Microsoft.Azure.Functions.Worker.Grpc.GrpcWorkerClientFactory.GrpcWorkerClient.SendStartStreamMessageAsync(IClientStreamWriter`1 requestStream) in D:\a\_work\1\s\src\DotNetWorker.Grpc\GrpcWorkerClientFactory.cs:line 74
2025-06-19T20:36:43.700760460Z    at Microsoft.Azure.Functions.Worker.Grpc.GrpcWorkerClientFactory.GrpcWorkerClient.StartAsync(CancellationToken token) in D:\a\_work\1\s\src\DotNetWorker.Grpc\GrpcWorkerClientFactory.cs:line 66
2025-06-19T20:36:43.700763755Z    at Microsoft.Azure.Functions.Worker.WorkerHostedService.StartAsync(CancellationToken cancellationToken) in D:\a\_work\1\s\src\DotNetWorker.Core\WorkerHostedService.cs:line 25
2025-06-19T20:36:43.700766450Z    at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>b__15_1(IHostedService service, CancellationToken token)
2025-06-19T20:36:43.700768947Z    at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List`1 exceptions, Func`3 operation)
2025-06-19T20:36:43.700771043Z    at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
2025-06-19T20:36:43.700772940Z    at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
2025-06-19T20:36:43.700774837Z    at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
2025-06-19T20:36:43.700776734Z    at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
2025-06-19T20:36:43.700778531Z    at Program.<Main>$(String[] args) in B:\sources\test\myfunc\Program.cs:line 19

What do I need to do to get an Azure Function running in docker (linux)?

Steps to reproduce

  1. func init --docker
  2. dotnet-isolated
  3. c#-isolated
  4. Open editor (I use Rider)
  5. Run the docker file

eholman avatar Jun 19 '25 20:06 eholman