【问题标题】:GET method for an Azure function within Azure Data Factory failsAzure 数据工厂中 Azure 函数的 GET 方法失败
【发布时间】:2020-09-24 07:38:07
【问题描述】:

我正在尝试调用基于GET 请求的HTTP 触发的Azure function。我按照推荐的步骤设置了链接服务,并且函数本身通过 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】:

事实证明,我使用了错误的 URI,并在末尾添加了 api,而我应该只是给出简单的函数名称

【讨论】:

    猜你喜欢
    • 2018-11-25
    • 2019-10-24
    • 2015-12-18
    • 2021-08-29
    • 2021-02-17
    • 2021-11-15
    • 1970-01-01
    • 2021-09-30
    • 2017-08-21
    相关资源
    最近更新 更多