【发布时间】:2022-12-28 17:08:43
【问题描述】:
我已经创建了一个非常简单的 Python V2 编程模型 HttpTrigger,它在我的本地 Azure 函数运行时机器上运行良好。
但是当我将它“部署”到 Azure 函数应用程序(Python v2 编程模型)时,我没有看到任何列为已注册的函数。并且调用相应的托管 URL 路由不起作用,尽管顶级 Azure 函数应用正在返回其主页,表明 Azure 认为托管运行时正在运行。函数应用程序存在(并且它从其根部的 URL 运行),但应用程序中未列出任何函数。部署没有错误;它说它已成功部署,但未列出。
其他人有这个问题吗?有办法解决吗?
简单的功能应用程序:
@app.function_name(name="HttpTrigger1")
@app.route(route="hello")
def test_function(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
)
接下来我可能会尝试 DevOps 管道部署,但我更喜欢直接从 VS Code 部署的简单性。我之前已经成功部署过 Typescript 函数。我可能会为这个 python 项目尝试旧的 V1 模型,但不想回溯到那个。
如果重要的话,我正在使用 Mac OSX 中的 VS Code。 Python 版本 3.9。
【问题讨论】:
标签: python azure visual-studio-code azure-functions