skip to Main Content

I am trying to run a function app written in C# locally in Visual Studio Professional 2022. But, I am getting the following error:

FUNCTIONS_INPROC_NET8_ENABLED app setting is not enabled in local.settings.json
Selected inproc6 host.
This version of the Azure Functions Core Tools requires your project to reference version 4.5.0 or later of Microsoft.NET.Sdk.Functions. Please update to the latest version. For more information, see: https://aka.ms/functions-core-tools-in-proc-sdk-requirement

The project file settings are as follows:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFramework>net6.0</TargetFramework>
        <AzureFunctionsVersion>v4</AzureFunctionsVersion>
    </PropertyGroup>
    <ItemGroup>
      <None Remove="appSettings.Production.json" />
    </ItemGroup>
    <ItemGroup>
        <Content Include="local.settings.json">
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
            <ExcludeFromSingleFile>true</ExcludeFromSingleFile>
            <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
        </Content>
        <Content Include="appsettings.Development.json">
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
            <ExcludeFromSingleFile>true</ExcludeFromSingleFile>
            <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
        </Content>
        <Content Include="appsettings.json">
            <CopyToOutputDirectory>Always</CopyToOutputDirectory>
            <ExcludeFromSingleFile>true</ExcludeFromSingleFile>
            <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
        </Content>
    </ItemGroup>
    <ItemGroup>
        <PackageReference Include="Microsoft.Azure.DurableTask.Core" Version="2.17.1" />
        <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" /> 
        <PackageReference Include="Microsoft.Azure.WebJobs.Extensions" Version="5.0.0" /> 
        <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="2.13.4" /> 
        <PackageReference Include="Microsoft.Azure.WebJobs.Logging.ApplicationInsights" Version="3.0.35" /> 
        <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
        <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
        <PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
        <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1" />
        <PackageReference Include="Microsoft.Extensions.Options" Version="7.0.1" />
        <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.3" />
        <PackageReference Include="SendGrid.Extensions.DependencyInjection" Version="1.0.1" />
        <PackageReference Include="Serilog.AspNetCore" Version="5.0.0" />
        <PackageReference Include="Serilog.Enrichers.Process" Version="2.0.2" />
        <PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
        <PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
        <PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" />
        <PackageReference Include="Serilog.Sinks.ApplicationInsights" Version="4.0.0" />
        <PackageReference Include="Serilog.Sinks.MSSqlServer" Version="5.7.0" />
        <PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" />
        <PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
        <PackageReference Include="System.Text.Encodings.Web" Version="7.0.0" />
        <PackageReference Include="System.Text.Json" Version="7.0.2" />
    </ItemGroup>
    <ItemGroup>
        <ProjectReference Include="..RailAPI.DataRailAPI.Data.csproj" />
        <ProjectReference Include="..RailAPI.ServicesRailAPI.Services.csproj" />
        <ProjectReference Include="..RailAPI.WorkersRailAPI.Workers.csproj" />
    </ItemGroup>
    <ItemGroup>
        <None Update="host.json">
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        </None>
    </ItemGroup>
    <ItemGroup>
        <FunctionsPreservedDependencies Include="Microsoft.Extensions.Caching.Abstractions.dll" />
        <FunctionsPreservedDependencies Include="Microsoft.Extensions.DependencyModel.dll" />
        <FunctionsPreservedDependencies Include="Microsoft.Extensions.DependencyInjection.dll" />
        <FunctionsPreservedDependencies Include="System.Text.Json.dll" />
    </ItemGroup>
    <ItemGroup>
      <Page Include="appsettings.Production.json" />
      <Page Include="local.settings.json" />
    </ItemGroup>
    <Target Name="FunctionsPostBuildDepsCopy" AfterTargets="PostBuildEvent">
        <Copy SourceFiles="$(OutDir)$(AssemblyName).deps.json" DestinationFiles="$(OutDir)bin$(AssemblyName).deps.json" />
    </Target>
    <Target Name="FunctionsPublishDepsCopy" AfterTargets="Publish">
        <Copy SourceFiles="$(OutDir)$(AssemblyName).deps.json" DestinationFiles="$(PublishDir)bin$(AssemblyName).deps.json" />
    </Target>
    <ItemGroup>
        <None Update="local.settings.json">
            <CopyToOutputDirectory>Never</CopyToOutputDirectory>
        </None>
    </ItemGroup>
</Project>

The local.settings.json file settings are as follows:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet"
  }
}

How can we resolve this issue?

I tried upgrading the Microsoft.NET.Sdk.Functions NuGET package and when I ran the app after that I got this error message

enter image description here

2

Answers


  1. Your local.settings.json should be similar as below

    {
      "IsEncrypted": false,
      "Values": {
        "AzureWebJobsStorage": "UseDevelopmentStorage=true",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet"
        "FUNCTIONS_INPROC_NET8_ENABLED": "1"
      }
    }
    

    Upgrade net6.0 to net8.0 and use version 4.5.0 for Microsoft.NET.Sdk.Functions.

    https://learn.microsoft.com/en-us/azure/azure-functions/functions-dotnet-class-library?tabs=v4%2Ccmd#updating-to-target-net-8

    Login or Signup to reply.
  2. I was getting this exact error message while trying to locally debug a dotnet-isolated function app that was previously able to be debugged locally without issue. No changes at all, and suddenly today I was getting your error.

    My fix: In your function project, if you have a Properties folder with a launchSettings.json file and there is a commandLineArgs that contains "–csharp", remove the –csharp.

    Before:

    {
      "profiles": {
        "MyProject.Function": {
          "commandName": "Project",
          "commandLineArgs": "--port 7177 --csharp --verbose",
          "launchBrowser": false,
          "environmentVariables": {
            "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
          }
        }
      }
    }
    

    After:

    {
      "profiles": {
        "MyProject.Function": {
          "commandName": "Project",
          "commandLineArgs": "--port 7177 --verbose",
          "launchBrowser": false,
          "environmentVariables": {
            "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
          }
        }
      }
    }
    

    So… even though it doesn’t look like you’re trying to run in dotnet-isolated, I still suggest checking the commandLineArgs in your launchSettings.json.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search