Azure Data Factory中的Azure函数的GET方法失败

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

我正在尝试调用以HTTP请求为基础的Azure function触发的GET。我按照建议的步骤设置了链接服务,该函数本身通过POSTMAN或Internet浏览器与查询字符串一起使用,但是当我尝试通过数据工厂进行调用时失败。

{
    "errorCode": "3608",
    "message": "Call to provided Azure function '' failed with status-'NotFound' and message - 'Invoking Azure function failed with HttpStatusCode - NotFound.'.",
    "failureType": "UserError",
    "target": "Azure Function1",
    "details": []
}

[我遇到了另一个stackoverflow帖子https://stackoverflow.com/a/54497119/4212430,其中提到了ADF的JSON响应。

此后,我更改了python代码,以提供HTTP响应作为JSON对象,如下所示

def main(req: func.HttpRequest) -> func.HttpResponse:
    logging.info('Python HTTP trigger function processed a request.')

    statename = req.params.get('statename')
    if not statename:
        try:
            req_body = req.get_json()
        except ValueError:
            pass
        else:
            statename = req_body.get('statename')

    if statename:
        initiate_main(statename)
        host.close()
        function_message = {"Response":"Successfully trasnferred BOM files"}
        return func.HttpResponse(
            json.dumps(function_message),
            mimetype="application/json", 
            status_code=200)
    else:
        function_message = {"Response":"Error in transferring files"}
        return func.HttpResponse(
            json.dumps(function_message), 
            mimetype="application/json", 
            status_code=400)

但是那也没有帮助。

json python-3.x azure azure-functions azure-data-factory-2
1个回答
0
投票

事实证明,我使用了错误的URI并在结尾处添加了api,而我本应该给出普通的函数名

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