最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

asp.net core - Visual Studio is having trouble creating a new Azure Function. Instead of the Azure Function icon, it's s

programmeradmin3浏览0评论

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.

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.

Share Improve this question edited Mar 18 at 9:32 Tiny Wang 16.5k2 gold badges18 silver badges38 bronze badges asked Mar 17 at 15:30 Akshay KumarAkshay Kumar 211 silver badge8 bronze badges 11
  • Install Azure Functions Tools in Visual Studio Installer and add Functions:Worker:HostEndpoint in host.json. – Dasari Kamali Commented Mar 18 at 6:16
  • Try running the function with the command func start func host --dotnet-isolated instead of using the VS Run button. – Dasari Kamali Commented Mar 18 at 6:29
  • Using the error message, I find this github issue which I'm afraid is helpful to you. I think this issue might occur due to Azure development module. Have you tried to open Visual Studio Installer and then reinstall the Azure development module? And maybe we can restart the computer. By the way, may I know the .Net version and Function type and VS type so that I could try to reproduce your issue? – Tiny Wang Commented Mar 18 at 8:32
  • I created a new .Net 8 Azure function isolation work model in my VS 2022 V17.12.0 and I didn't reprduce your issue. – Tiny Wang Commented Mar 18 at 9:36
  • 1 Isolated work model requires Microsoft.Azure.Functions.Worker. May I know why you have Microsoft.NET.Sdk.Functions reference in your function? I upgraded my VS to 17.13.3 just now and I still can't reproduce your issue. – Tiny Wang Commented Mar 18 at 9:55
 |  Show 6 more comments

1 Answer 1

Reset to default 0

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

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'.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论