gpt4 book ai didi

c# - 从 .NET 3 迁移到 .NET 5 时,Azure Function 中出现错误 "Did not find functions with language [dotnet-isolated]"

转载 作者:行者123 更新时间:2023-12-02 05:50:14 27 4
gpt4 key购买 nike

我正在尝试将在 .NET 3.1 上完美运行的 Azure Function 迁移到 .NET 5。我按照 Microsoft 的 GitHub 指南进行操作,但仍然无法在本地运行或调试(甚至没有尝试发布到 Azure)。

我收到此错误:

[2021-09-05T09:49:33.066Z] A host error has occurred during startup operation 'bb37a6db-b6f4-4396-bb9b-cb5ae0bba387'.
[2021-09-05T09:49:33.067Z] Microsoft.Azure.WebJobs.Script: Did not find functions with language [dotnet-isolated].

并且正在引发此异常:

这是我的 Program.cs:

static async Task Main(string[] args)
{
var host = new HostBuilder()
.ConfigureAppConfiguration(c =>
{
c.AddCommandLine(args);
})
.ConfigureServices(s =>
{
s.AddLogging();
})
.Build();

await host.RunAsync();
}

这是我的项目文件:

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
<UserSecretsId>76d0a5ed-221b-4b35-8ff4-3ee33d393196</UserSecretsId>
<OutputType>Exe</OutputType>
<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
</PropertyGroup>
<ItemGroup>
<None Remove="global.json" />
</ItemGroup>
<ItemGroup>
<Content Include="global.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.5.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage" Version="4.0.4" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.0.4" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.2" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.11.1" />
<PackageReference Include="System.Linq.Async" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<None Update="config.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>

我的 local.settings.json:

{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "HIDDEN",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
}
}

我的主机.json:

{
"logging": {
"fileLoggingMode": "always",
"logLevel": {
//"QueueWorkers.EmailQueueWorker": "Trace",
//"QueueWorkers.EmailQueueWorker.EmailQueueWorker": "Trace",
"default": "Information",
"Function": "Trace",
"Host.Results": "Error",
"Host.Aggregator": "Trace"
},
"applicationInsights": {
//"samplingExcludedTypes": "Request",
"samplingSettings": {
"isEnabled": true
}
},
"console": {
"isEnabled": "true"
}
},
"Values": {
"AzureWebJobsStorage": "HIDDEN",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
},
"extensions": {
"queues": {
"maxDequeueCount": 5,
"maxPollingInterval": "00:00:02"
}
},
"version": "2.0"
}

谢谢

最佳答案

在 Azure 中导航到您的函数,然后在“设置”->“配置”部分中更改应用程序设置:

"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"

enter image description here

关于c# - 从 .NET 3 迁移到 .NET 5 时,Azure Function 中出现错误 "Did not find functions with language [dotnet-isolated]",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69104798/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com