Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to turn off Asp.Net Core Integration on Isolated runtime on v4 with .NET 8 #2594

Closed
varkey98 opened this issue Jul 11, 2024 · 3 comments
Closed

Comments

@varkey98
Copy link

varkey98 commented Jul 11, 2024

Description

I'm trying to use the default template created by vs code on Mac. this is the code in my Program.cs

var host = new HostBuilder()
    // .ConfigureFunctionsWebApplication(app => {
    //     app.UseMiddleware<MyMiddleware>();
    // })
    .ConfigureFunctionsWorkerDefaults((app) => {
        app.UseMiddleware<MyMiddleware>();
    })
    .ConfigureServices(services => {
        services.AddApplicationInsightsTelemetryWorkerService();
        services.ConfigureFunctionsApplicationInsights();
    })
    .Build();

With the above code, it throws the following error:

/Users/test/Projects/dotnetserver/IsolatedFunction/Program.cs(10,6): error AZFW0014: The registration for method 'ConfigureFunctionsWebApplication' is expected for ASP.NET Core Integration. (https://aka.ms/azfw-rules?ruleid=AZFW0014) [/Users/test/Projects/dotnetserver/IsolatedFunction/IsolatedFunction.csproj]

I understand this is because its trying to build an Asp.Net Core based function, but how to turn that behavior off?

Steps to reproduce

Use the default template provided by vs code for HTTP Trigger functions on .NET 8 isolated runtime. Update the program.cs code as mentioned above

@varkey98 varkey98 added the potential-bug Items opened using the bug report template, not yet triaged and confirmed as a bug label Jul 11, 2024
@kshyju
Copy link
Member

kshyju commented Jul 11, 2024

If you choose not to use ASP.NET Core integration, remove the package reference to Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.

If this package is referenced in your dotnet-isolated function app, you should use ConfigureFunctionsWebApplication.

https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide?tabs=windows#aspnet-core-integration

@kshyju kshyju added Needs: Author Feedback and removed Needs: Triage (Functions) potential-bug Items opened using the bug report template, not yet triaged and confirmed as a bug labels Jul 11, 2024
@varkey98
Copy link
Author

Thanks let me try that

@varkey98
Copy link
Author

Yes. it worked, closing this issue, thanks. But I think it should be a more straightforward configuration than removing a project reference. Also I couldn't find this in any docs, that also needs an update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants