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

Update core tools to emit warning if user is running .NET8 inproc app but without FUNCTIONS_INPROC_NET8_ENABLED #4155

Open
aishwaryabh opened this issue Nov 8, 2024 · 6 comments · May be fixed by #4300

Comments

@aishwaryabh
Copy link
Contributor

Description

Today we require that local.settings.json has "FUNCTIONS_INPROC_NET8_ENABLED": "1" for a .NET8 inproc app. A lot of users get confused why the .NET 8 host doesn't launch when they are running an inproc .NET 8 app, so emitting a log/warning would be nice to let them know if they intend on running the .NET 8 host they should set the variable.

@liliankasem
Copy link
Member

Is it possible to have core tools set FUNCTIONS_INPROC_NET8_ENABLED automatically? Can we detect the target framework and make that decision ourselves without having customers set this flag?

@SeanFeldman
Copy link

Wherever it's auto-detected and set or a warning is emitted, do something. As of now, it's an extremely poor experience, and developers have no indication of what's going on and why there's a failure.

@saadalia
Copy link

saadalia commented Feb 3, 2025

Hi @liliankasem, @aishwaryabh

I’ve been looking into resolving the confusion around launching .NET 8 inproc apps without having to set FUNCTIONS_INPROC_NET8_ENABLED manually and came across two promising approaches. Here’s a precise summary of each:

Approach 1: csproj-Based Detection (PR #4248)
Pros:

  • Easy to detect the csproj file since we expect one and only one csproj file in the root directory.

if (csProjFiles.Count + fsProjFiles.Count > 1)
{
throw new CliException($"Can't determine Project to build. Expected 1 .csproj or .fsproj but found {csProjFiles.Count + fsProjFiles.Count}");
}

  • We can load the csproj file only instead of the full DLL.

Cons:

  • Creates a dependency on the csproj structure; for example, if multiple frameworks exist in TargetFramework (already handled, but similar issues might occur).
    Some edge cases might persist.
  • Since the build will change the Environment.CurrentDirectory, I need a way to keep track of the original script root, below is how I managed to do it, but I appreciate if we have better way to do it.

https://github.com/saadalia/azure-functions-core-tools/blob/c302057dd953722db5226ffd6ac367a0307c2d91/src/Azure.Functions.Cli/Actions/HostActions/StartHostAction.cs#L664-L665

Approach 2: DLL-Based Detection (PR #4249)
Pros:

Detection is based on the compiled DLL, we will almost eliminate the edge cases (for example, multi-target scenarios are better handled).

Cons:

  • I need a straightforward way to identify the main DLL.

Both approaches aim to streamline .NET 8 detection by automating the process. It would be valuable to discuss which approach fits best with our deployment scenarios and overall architecture. Looking forward to your thoughts on these options.

@mattchenderson
Copy link
Contributor

I'd propose to repurpose this item slightly. Since .NET 6 is out of support, we should simply provide a warning whenever we aren't going down the .NET 8 path, with a pointer to instructions to migrate. That can include a warning about missing this setting.

Draft proposed text (warning level):

Starting application with .NET 6 runtime. .NET 6 is no longer supported, and you should migrate to a supported version. See https://aka.ms/azure-functions/dotnet/net8-in-process for more information. If you intend to target .NET 8 on the in-process model, make sure that FUNCTIONS_INPROC_NET8_ENABLED is set to "1".

@VineethReyya
Copy link
Contributor

VineethReyya commented Mar 13, 2025

@liliankasem @aishwaryabh we are already providing a warning when runtime is inproc8

Please find the screenshot below:

Image

We're displaying a warning currently—do you think it's adequate, or should we add more detail?

@liliankasem
Copy link
Member

Does this warning show when you run func start?

Let's update the message to match what Matthew has drafted out above ^

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