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?