.NET 8 隔离的 Azure 功能不再运行

问题描述 投票:0回答:1

今天早上我看到 Azure 函数不再运行,而我没有对代码/配置进行任何更改。我尝试禁用和启用该功能,但由于我禁用了它,它不再出现在我的 Azure Function 仪表板上。 这是我在日志中得到的内容:

enter image description here

有时我会收到不同的错误消息:

未找到工作职能。尝试制定你的工作类别和方法 民众。如果您使用绑定扩展(例如 Azure 存储、 ServiceBus、定时器等)确保您已调用注册 启动代码中扩展的方法(例如 生成器.AddAzureStorage(), 生成器.AddServiceBus(), builder.AddTimers() 等)。

一周前我确实将依赖项更新为以下内容:

<ItemGroup>
    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.23.0"/>
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.3.1" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.4"/>
    <PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.4.0" />
</ItemGroup>

在我的测试环境中,使用相同的配置,它工作得很好。我仔细检查了配置,并且为隔离的工作人员提供了正确的配置。

我的 Azure 函数是 TimerTrigger:

[Function(nameof(ReservationConfirmation))]
public async Task RunAsync([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer)
{
    // ...
}

程序.cs:

var host = new HostBuilder()
    .ConfigureFunctionsWorkerDefaults()
    .ConfigureServices(services =>
    {
        services.AddApplicationInsightsTelemetryWorkerService();
        services.ConfigureFunctionsApplicationInsights();

        services.Configure<LoggerFilterOptions>(options =>
        {
            var toRemove = options.Rules.FirstOrDefault(rule => rule.ProviderName == "Microsoft.Extensions.Logging.ApplicationInsights.ApplicationInsightsLoggerProvider");

            if (toRemove is not null)
            {
                options.Rules.Remove(toRemove);
            }
        });
    })
    .Build();

await host.RunAsync();

我不知道我错过了什么以及如何解决它。

azure-functions .net-8.0
1个回答
0
投票

问题来自于我使用的部署模式,这是上传神器GHA引入的问题

就我而言,它与代码/AF 配置无关。如果您遇到此问题,还请检查您的部署。

© www.soinside.com 2019 - 2024. All rights reserved.