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

Azure Durable Functions Python中get_input方法返回null问题求助

问题根因

导致get_input()返回null的核心原因是编排函数没有收到HTTP触发器传递的请求载荷,常见触发场景有3种:

  • HTTP Starter启动编排函数时,没有将解析后的请求JSON作为input_参数传入start_new方法
  • Postman请求未携带Content-Type: application/json请求头,导致HTTP触发器无法正确解析JSON body,拿到的请求载荷本身就是None
  • 编排函数中get_input()调用逻辑错误,比如在重入逻辑中错误覆盖了取值结果
修复步骤
  1. 修正HTTP Starter函数的传参逻辑,必须显式将解析后的请求体传入编排启动方法,参考代码:
import azure.functions as func
import azure.durable_functions as df

async def main(req: func.HttpRequest, starter: str) -> func.HttpResponse:
    client = df.DurableOrchestrationClient(starter)
    # 解析请求JSON
    req_body = req.get_json()
    # 启动编排时传入input_参数
    instance_id = await client.start_new(
        "DurableFunctionsOrchestrator1",
        None,
        input_=req_body
    )
    return client.create_check_status_response(req, instance_id)
  1. 检查Postman请求配置,在Headers栏添加Content-Type: application/json配置,确保请求体被正确识别为JSON格式。

  2. 编排函数中直接调用get_input()取值即可,参考代码:

import azure.durable_functions as df

def orchestrator_function(context: df.DurableOrchestrationContext):
    input_data = context.get_input()
    # 可直接读取input_data["points"]取值
    return input_data

main = df.Orchestrator.create(orchestrator_function)
验证方法

可在HTTP Starter函数中添加日志打印req_body的取值,若打印结果为null则说明请求解析失败,若能正常打印{"points":222}则说明是编排启动时未传参导致的问题。

内容的提问来源于stack exchange,提问作者Ee Chin

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.06 16:57:04