You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

.NET 6 Isolated Azure Functions部署后Timer Trigger不触发求助

问题:Azure Functions .NET 6 Isolated 部署后Timer Trigger无法触发

最近将Azure Functions项目切换为.NET 6 Isolated运行时,本地运行正常,但部署到Azure后Timer Trigger始终无法触发。已查阅相关帖子并尝试修改,问题仍未解决。以下是项目相关配置及日志信息:

Program.cs

using Microsoft.Extensions.Hosting;

var host = new HostBuilder()
    .ConfigureFunctionsWorkerDefaults()
    .Build();

host.Run();

函数代码

using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Logging;

namespace MyProj.AzureFunctions
{
    public class Functions
    {
        private readonly ILogger _logger;

        public Functions(ILoggerFactory loggerFactory)
        {
            _logger = loggerFactory.CreateLogger<Functions>();
        }

        [Function("Health")]
        public void Health([TimerTrigger("* * * * *")] MyInfo myTimer, ILogger log)
        {
            log.LogInformation("Health Check Successful.");
        }
    }

    public class MyInfo
    {
        public MyScheduleStatus ScheduleStatus { get; set; }

        public bool IsPastDue { get; set; }
    }

    public class MyScheduleStatus
    {
        public DateTime Last { get; set; }

        public DateTime Next { get; set; }

        public DateTime LastUpdated { get; set; }
    }
}

host.json配置

{
    "version": "2.0",
    "logging": {
        "applicationInsights": {
            "samplingExcludedTypes": "Request",
            "samplingSettings": {
                "isEnabled": true
            }
        }
    }
}

local.settings.json配置

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

.csproj配置

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
    <OutputType>Exe</OutputType>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.8.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.7.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>

Azure Functions平台设置

Azure Functions设置

部署后日志信息

查看/LogFiles/Application/Functions/Host下的日志文件,未找到函数触发记录,仅重复记录主机运行状态:

2023-02-28T19:48:29.700 [Information] Host Status: {
  "id": "devfunctions",
  "state": "Running",
  "version": "4.15.2.20177",
  "versionDetails": "4.15.2+28e9550320b13137f4eaf16483ebcdb630699506",
  "platformVersion": "99.0.10.793",
  "instanceId": "de79fd99bf2007cea7cba17a54c929b84f3dafad58d9cd5c0c16eccc0cd59790",
  "computerName": "10-30-3-159",
  "processUptime": 4170653,
  "functionAppContentEditingState": "Unknown"
}

内容的提问来源于stack exchange,提问作者Dillon Drobena

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.29 13:35:13