Open anime-shed opened 6 months ago
Thanks for informing will check and confirm the same.
I checked it seems fine.can you try again else share your code also.
I'm sorry, it's a private project, so I won't be able to share the code. I can provide snippets that may help you debug the cause.
I tried to try again on my project, but for some reason, I am facing:
[2024-05-28T15:16:31.037Z] Found Using for user secrets file configuration.
[2024-05-28T15:16:32.849Z] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
[2024-05-28T15:16:32.899Z] The 'FUNCTIONNAME' function is in error: The binding type(s) 'blobTrigger' are not registered. Please ensure the type is correct and the binding extension is installed.
For detailed output, run func with --verbose flag.
I am also having the same issue after upgrading from .Net 6 to .Net 8.
Microsoft.Azure.WebJobs.Script: Error building configuration in an external startup class. FileNetWorkFlows.Workflows: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=8.0.0.0
I even attempted adding that package to the project explicitly.
@dsgb1987, will it be possible to share your code snippet for @bhagyshricompany since I am facing an error on my end?
sample code using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Azure.Functions.Worker; using Microsoft.Extensions.Logging;
namespace FunctionApp1
{
public class Function1
{
private readonly ILogger
public Function1(ILogger<Function1> logger)
{
_logger = logger;
}
[Function("Function1")]
public IActionResult Run([HttpTrigger(AuthorizationLevel.Function, "get", "post")] HttpRequest req)
{
_logger.LogInformation("C# HTTP trigger function processed a request.");
return new OkObjectResult("Welcome to Azure Functions!");
}
}
}
I'm also having the same issue after upgrading from .net core 6.0 to 8.0 in an azure function. Runs locally but fails in Azure with the above error.
it seems this problem happens only when
<Nullable>enable</Nullable>
it seems this problem happens only when
<Nullable>enable</Nullable>
It runs fine with the IDEs (Visual Studio or Rider).
But on command-line func host start
, the problem occurs.
I'm using azfunc core tools 4.0.5858.
can you upgrade your version.
can you upgrade your version.
You mean me? My version is the latest now. (4.0.5858)
I also tried downgrading to your version (4.0.5801) but still the same issue.
Try to upgeade your asp.net core versions to latest one from 1.2.0 tolatest.Thanks
Thanks. I was using in-progress model. I switched to worker model and the problem is gone.
@quellatalo can you share what you changed?
@anime-shed
@quellatalo can you share what you changed?
I was using InProgress Model (Microsoft.NET.Sdk.Functions
) instead of Worker Model. The project was configured with net6.0
, and Nullable
enabled.
When I changed the target framework to net8.0
, I got the same error message about loading Microsoft.Extensions.Configuration.Abstractions, Version=8.0.0.0
.
NOTE: This problem does not occur when I run the az function using the IDEs (VisualStudio or Rider). It only happens with func core tools func host start
.
I found 2 ways:
I tried to investigate by simplify/minimize the project as much as possible.
Then when I removed the <Nullable>enable</Nullable>
line, the problem was gone.
However, this would break the whole project design. So, I need another approach.
There's an article about retiring InProgress Model. So I tried to switch to Worker model to see how it goes... and it just worked, even with Nullable enabled.
Considering your initial implementation is on Worker Model already. I think I can't really help you :(. Maybe checking installed versions might help. (There's a new func core tool 4.0.5907 released.)
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>true</IsPackable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.22.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.2.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.2.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.3.2" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.6" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
func --version
: 4.0.5907
dotnet --version
: 8.0.302
In my case, I also switched to the worker model after reading the documentation shared, but for me, the error occurred while debugging with Visual Studio. I will close this for now since I no longer have the original implementation that had the issue.
In my case, I also switched to the worker model after reading the documentation shared, but for me, the error occurred while debugging with Visual Studio. I will close this for now since I no longer have the original implementation that had the issue.
Same here for Durable Functions.
@Wind010 We had the same issue with durable functions. The solution is to remove bin anb obj folders, rebuild and this error will despair. All orchestrators attributes and reference classes should be changed to those from Microsoft.Azure.Functions.Worker.Extensions.DurableTask. Here are our packages: Keep in mind that not all functions from Microsoft.Azure.WebJobs.Extensions.DurableTask where mover already. Here an example: https://github.com/Azure/azure-functions-durable-extension/issues/2810
I was again able to reproduce this issue and was able to fix to a point:
<TargetFramework>net8.0-windows</TargetFramework>
So, currently, the final thing looks like this:csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<DockerFastModeProjectMountDirectory>/home/site/wwwroot</DockerFastModeProjectMountDirectory>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.23.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.3.2" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage.Blobs" Version="6.3.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.4" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
<PackageReference Include="Microsoft.Extensions.Azure" Version="1.7.3" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
<PackageReference Include="DotNetZip" Version="1.16.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.2" />
<PackageReference Include="CsvHelper" Version="31.0.3" />
<PackageReference Include="Polly" Version="8.3.1" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="Telegram.Bot" Version="19.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Core\Core.csproj" />
<ProjectReference Include="..\Libraries\Libraries.CommonEnums\Libraries.CommonEnums.csproj" />
<ProjectReference Include="..\Libraries\Library.ResponseHelpers\Library.ResponseHelpers.csproj" />
<ProjectReference Include="..\Libraries\Library.StorageWriter\Library.StorageWriter.csproj" />
</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>
Program.cs
var host = new HostBuilder()
.ConfigureLogging(configureLogging =>
{
var loggerConfiguration = new LoggerConfiguration()
.Enrich.FromLogContext()
.WriteTo.Console();
#if DEBUG
loggerConfiguration
.MinimumLevel.Information();
#else
loggerConfiguration
.MinimumLevel.Warning();
#endif
configureLogging.AddSerilog(loggerConfiguration.CreateLogger());
})
.ConfigureFunctionsWebApplication()
.ConfigureAppConfiguration((hostingContext, configBuilder) =>
{
var env = hostingContext.HostingEnvironment;
configBuilder
.AddJsonFile($"appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables()
;
})
.ConfigureServices((context, services) =>
{
services.AddApplicationInsightsTelemetryWorkerService();
Dependencies.SetUp(services,context.Configuration);
})
.Build();
host.Run();
DOCKERFILE
# This stage is used when running from VS in fast mode (Default for Debug configuration)
FROM mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated8.0 AS base
WORKDIR /home/site/wwwroot
EXPOSE 8080
# This stage is used to build the service project
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["FunctionApp/FunctionApp.csproj", "FunctionApp/"]
COPY ["Core/Core.csproj", "Core/"]
COPY ["Libraries/Libraries.CommonEnums/Libraries.CommonEnums.csproj", "Libraries/Libraries.CommonEnums/"]
COPY ["Libraries/Library.ResponseHelpers/Library.ResponseHelpers.csproj", "Libraries/Library.ResponseHelpers/"]
COPY ["Libraries/Library.StorageWriter/Library.StorageWriter.csproj", "Libraries/Library.StorageWriter/"]
COPY ["Libraries/Libraries.Cryptography/Libraries.Cryptography.csproj", "Libraries/Libraries.Cryptography/"]
RUN dotnet restore "./FunctionApp/FunctionApp.csproj"
COPY . .
WORKDIR "/src/FunctionApp"
RUN dotnet build "./FunctionApp.csproj" -c $BUILD_CONFIGURATION -o /app/build
# This stage is used to publish the service project to be copied to the final stage
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./FunctionApp.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration)
FROM base AS final
WORKDIR /home/site/wwwroot
COPY --from=publish /app/publish .
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
Right now, my problem is that Docker is on a Linux-based container, and <TargetFramework>net8.0-windows</TargetFramework>
breaks that, so Is there a way I can fix that?
Also, for some reason, this is working with func start
:
with csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<DockerFastModeProjectMountDirectory>/home/site/wwwroot</DockerFastModeProjectMountDirectory>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.23.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.3.2" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage.Blobs" Version="6.3.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.4" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
<PackageReference Include="Microsoft.Extensions.Azure" Version="1.7.3" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
<PackageReference Include="DotNetZip" Version="1.16.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.2" />
<PackageReference Include="CsvHelper" Version="31.0.3" />
<PackageReference Include="Polly" Version="8.3.1" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="Telegram.Bot" Version="19.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Core\Core.csproj" />
<ProjectReference Include="..\Libraries\Libraries.CommonEnums\Libraries.CommonEnums.csproj" />
<ProjectReference Include="..\Libraries\Library.ResponseHelpers\Library.ResponseHelpers.csproj" />
<ProjectReference Include="..\Libraries\Library.StorageWriter\Library.StorageWriter.csproj" />
</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>
with <TargetFramework>net8.0</TargetFramework>
New V4 app or existing V3 app migrated to V4: New App in V4
Also verified in dotnet 8 sdk
Case
We are creating Azure function v4 with .net core 8.
Error:
Packages