azureasp.net-coreazure-functionsazure-functions-isolated

Visual Studio is having trouble creating a new Azure Function. Instead of the Azure Function icon, it's showing the C# icon


I'm trying to create a new Azure Function in Visual Studio, but I'm encountering an issue. When I attempt to create the function, instead of the Azure Function icon, it displays the C# icon. This is preventing me from properly setting up the Azure Function project. Has anyone experienced this issue before? Any solutions or suggestions would be appreciated!

Unhandled exception. System.InvalidOperationException: Configuration is missing the 'HostEndpoint' information. Please ensure an entry with the key 'Functions:Worker:HostEndpoint' is present in your configuration.

enter image description here


Solution

  • I got the same error when I created a .NET 8.0 Isolated Azure function using Visual Studio version 17.12.5.

    enter image description here

    I have resolved the issue by restarting the system.

    Install Azure function core tools latest version.

    .csproj:

    <Project Sdk="Microsoft.NET.Sdk">
      <PropertyGroup>
        <TargetFramework>net8.0</TargetFramework>
        <AzureFunctionsVersion>v4</AzureFunctionsVersion>
        <OutputType>Exe</OutputType>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
      </PropertyGroup>
      <ItemGroup>
        <FrameworkReference Include="Microsoft.AspNetCore.App" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="2.0.0" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="2.0.0" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.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>
    

    local.settings.json:

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

    Able to run the function now:

    Azure Functions Core Tools
    Core Tools Version:       4.0.6821 Commit hash: N/A +c09a2033faa7ecf51b3773308283af0ca9a99f83 (64-bit)
    Function Runtime Version: 4.1036.1.23224
    
    [2025-03-19T12:40:02.797Z] Found C:\Users\uname\Source\Repos\Simplefunction\Simplefunction.csproj. Using for user secrets file configuration.
    [2025-03-19T12:40:08.544Z] Azure Functions .NET Worker (PID: 1804) initialized in debug mode. Waiting for debugger to attach...
    [2025-03-19T12:40:08.656Z] Worker process started and initialized.
    
    Functions:
    
            Function1: [GET,POST] http://localhost:7142/api/Function1
    
    For detailed output, run func with --verbose flag.
    [2025-03-19T12:40:12.809Z] Executing 'Functions.Function1' (Reason='This function was programmatically called via the host APIs.', Id=5ea43064-e352-494a-80ba-885f2464019b)
    [2025-03-19T12:40:13.454Z] C# HTTP trigger function processed a request.
    [2025-03-19T12:40:13.472Z] Executing OkObjectResult, writing value of type 'System.String'.
    [2025-03-19T12:40:13.602Z] Executed 'Functions.Function1' (Succeeded, Id=5ea43064-e352-494a-80ba-885f2464019b, Duration=873ms)
    [2025-03-19T12:40:13.895Z] Host lock lease acquired by instance ID '000000000000000000000000F72731CC'.