Azure functions migrated to dotnet-isolated now shows error "Worker failed to index functions"

KonradSL 76 Reputation points
2024-02-12T15:51:45.7933333+00:00

I migrated my Azure Function App to the new dotnet-isolated with .NET8. It compiled well - but when I start the app from within VST for debugging, it shows errors:

Worker failed to index
functionsResult: Failure
Exception: System.InvalidOperationException: Functions must declare at least one binding. No bindings were found in the function $func
.at Microsoft.Azure.Functions.Worker.GrpcWorker.GetFunctionMetadataAsync(String functionAppDirectory) in D:\a\_work\1\s\src\DotNetWorker.Grpc\GrpcWorker.cs:line 165Stack:    at Microsoft.Azure.Functions.Worker.GrpcWorker.GetFunctionMetadataAsync(String functionAppDirectory) in D:\a\_work\1\s\src\DotNetWorker.Grpc\GrpcWorker.cs:line 165.

But nevertheless, it continue to run and find all my functions:

Worker process started and initialized.
Functions:
        CleanupData: timerTrigger
        CreateOpenTests: timerTrigger
...

But the error is very annoying. You don't want red error messages in the console. My project file after the migration looks like this:

<Project Sdk="Microsoft.NET.Sdk">
	<PropertyGroup>
		<TargetFramework>net8.0</TargetFramework>
		<AzureFunctionsVersion>v4</AzureFunctionsVersion>
		<OutputType>Exe</OutputType>
	</PropertyGroup>
	<ItemGroup>
		<None Remove="Migrations\20200509132620_VisualDateNewField.cs~RF201e58c6.TMP" />
	</ItemGroup>
	<ItemGroup>
		<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask" Version="1.1.1" />
		<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask.SqlServer" Version="1.2.2" />
		<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Tables" Version="1.3.0" />
		<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.3.0" />
		<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.1">
			<PrivateAssets>all</PrivateAssets>
			<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
		</PackageReference>
		<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.1" />
		<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.1">
			<PrivateAssets>all</PrivateAssets>
			<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
		</PackageReference>
		<FrameworkReference Include="Microsoft.AspNetCore.App" />
		<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.21.0" />
		<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.0" />
		<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.2.1" />
		<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
		<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.2.0" />
		<PackageReference Include="OAuth.DotNetCore" Version="3.0.1" />
		<PackageReference Include="ProjNet" Version="2.0.0" />
		<PackageReference Include="System.Configuration.ConfigurationManager" Version="8.0.0" />
	</ItemGroup>
	<ItemGroup>
		<None Update="host.json">
			<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
		</None>
		<None Update="local.settings.json">
			<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
			<CopyToPublishDirectory>Never</CopyToPublishDirectory>
		</None>
	</ItemGroup>
	<ItemGroup>
		<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
	</ItemGroup>
</Project>

And my Program.cs is also the default one:

public class Program
{
   static void Main(string[] args)
   {
      String SqlConnection = Environment.GetEnvironmentVariable("SqlConnectionString");
      var host = new HostBuilder()
                .ConfigureFunctionsWebApplication()
                .ConfigureServices(services =>
                {
                    services.AddApplicationInsightsTelemetryWorkerService();
                    services.ConfigureFunctionsApplicationInsights();
                    services.AddDbContext<MyContext>(options => options.UseSqlServer(SqlConnection, opts => opts.CommandTimeout(1000))
                                    .LogTo(Console.WriteLine, LogLevel.Information)
                                    .ConfigureWarnings(b => b.Log((RelationalEventId.CommandExecuted, LogLevel.Trace))));
                })
                .Build();
            host.Run();
   }
}

But where does the error comes from, if at the end all functions are started and indexed properly?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,936 questions
Developer technologies | C#
{count} vote

Accepted answer
  1. MikeUrnun 9,777 Reputation points Moderator
    2024-02-16T07:58:49.59+00:00

    Hi @KonradSL - Thanks for providing additional info. Does something like the following work?

    [Function("ProcessSingleCityMessageList")]
    public async Task ProcessSingleCityMessageList([OrchestrationTrigger] IDurableOrchestrationContext context, ILogger log)
    {
    
    }
    

    The use of the Function attribute tells the Host process that ProcessSingleCityMessageList() should be one of the functions that needs to be synced/indexed but it doesn't have a valid input hence the "Functions must declare at least one binding. No bindings were found in the function" error message.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.