未找到 HTTP 触发器

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

我尝试在 Azure 门户上使用 python 部署我的 azure 函数,但出现错误“未找到 HTTP 触发器”,它在 vs code 中工作,我尝试使用默认的 http 触发器函数,它工作得很好。 enter image description hereenter image description here

我添加了

app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)
@app.route(route="http_trigger")

这仍然面临问题。 还降级了 VS Code 中的 Azure Functions 核心工具。

python triggers azure-functions
1个回答
0
投票

未找到 HTTP 触发器

最初,我在将函数部署到 azure 门户时也遇到了同样的错误。

enter image description here

  • 我已在本地和天蓝色门户中添加了此
    AzureWebJobsFeatureFlags:EnableWorkerIndexing
    应用程序设置并重新部署了该功能。然后它就按预期工作了。

我已经使用运行时堆栈python创建了Http触发函数。检查下面的功能代码:

功能代码:

import azure.functions as func
import logging

app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)

@app.route(route="http_trigger")
def http_trigger(req: func.HttpRequest) -> func.HttpResponse:
    logging.info('Python HTTP trigger function processed a request.')

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

    if name:
        return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.")
    else:
        return func.HttpResponse(
            "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
            status_code=200
        )
  • 当函数指定不正确时,可能会出现Isuue。检查代码和函数语法。

local.settings.json:

{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "your-storage conn-string",
"FUNCTIONS_WORKER_RUNTIME": "python",
"AzureWebJobsFeatureFlags": "EnableWorkerIndexing"
}
}

我在门户中创建了一个包含消费计划的功能应用程序,并将该功能部署到门户中。检查以下配置:

enter image description here

以上功能已成功部署到azure门户中。检查下面:

输出:

enter image description here

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