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

部署后Azure Timer Trigger Function无法执行,门户测试报500错误

Azure函数部署后触发同步失败(500内部服务器错误)问题排查

用VS Code创建的Python Timer Trigger Azure函数,本地运行完全正常,但部署到Azure后无法执行。通过门户测试或运行时收到如下错误:
Function triggers synchronization failed due to Response status code does not indicate success: 500 (Internal Server Error)

部署过程无异常,函数已显示在门户中,但触发器无法自动或手动执行,尝试HTTP函数也出现相同问题。使用的是200美元免费信用订阅计划,非即用即付模式。

部署输出日志

2:23:54 AM func-afaq: Uploaded package to storage blob. Deployment is partially successful from here.
2:23:54 AM func-afaq: [RemoveWorkersStep] starting.
2:23:55 AM func-afaq: RemoveAllWorkers, statusCode = NoContent
2:23:55 AM func-afaq: Reset all workers was successful.
2:23:55 AM func-afaq: [SyncTriggerStep] starting.
2:23:55 AM func-afaq: Waiting 60 seconds for the workers to recycle with deployed content.
2:24:55 AM func-afaq: [CleanUpStep] starting.
2:24:55 AM func-afaq: Cleaned the source packages directory.
2:24:55 AM func-afaq: Cleaned the result artifact directory.
2:24:55 AM func-afaq: Finished deployment pipeline.
2:24:57 AM func-afaq: FunctionHostSyncTrigger, statusCode = InternalServerError
2:25:02 AM func-afaq: Querying triggers...

相关代码与配置

函数代码(function_app.py)

import logging
import azure.functions as func

app = func.FunctionApp()

@app.timer_trigger(schedule="0 * * * * *", arg_name="myTimer", run_on_startup=False,
              use_monitor=False) 
def timer_trigger(myTimer: func.TimerRequest) -> None:
    if myTimer.past_due:
        logging.info('The timer is past due!')

    logging.info('Python timer trigger function executed.')

host.json配置

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[4.*, 5.0.0)"
  }
}

local.setting.json配置

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "python",
    "AzureWebJobsFeatureFlags": "EnableWorkerIndexing"
    
  }
}

额外尝试结果

部署VS Code提供的简单模板,本地运行正常,但部署后出现加载错误:

Error while loading
Ask questions and use troubleshooting tools to investigate these errors.Diagnose and solve problems
Encountered an error (InternalServerError) from host runtime

可能的原因与排查方向

  • 订阅资源限制:免费信用订阅可能存在CPU、内存等资源配额限制,导致运行时无法启动。检查函数应用的「使用情况 + 配额」页面,确认是否有资源耗尽情况。
  • 存储账户异常:Azure Functions依赖存储账户完成触发器同步、日志存储等操作。确认部署后函数应用配置的AzureWebJobsStorage连接字符串有效,存储账户未被禁用、权限配置正确。
  • 扩展包兼容性:host.json中指定的扩展包版本[4.*,5.0.0)可能与当前函数运行时版本不兼容。尝试锁定到具体稳定版本(如[4.15.0, 5.0.0)),或降级到3.x版本测试。
  • Python版本不匹配:本地使用的Python版本与Azure函数应用配置的运行时版本不一致。检查函数应用「配置」->「常规设置」中的Python版本,确保和本地开发环境一致。
  • 部署包损坏:虽部署日志显示成功,但可能存在包上传损坏情况。尝试重新打包部署,或使用func azure functionapp publish命令重新部署。
  • 功能标志冲突:本地配置的AzureWebJobsFeatureFlags: EnableWorkerIndexing在Azure环境中可能与运行时冲突。尝试在门户的函数应用配置中移除该标志,或恢复默认值。

内容的提问来源于stack exchange,提问作者Afaq Bukhari.

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.13 09:37:35