从 VS Code 部署 Azure 函数失败

时间:2021-05-18 05:01:27

标签: azure-functions azure-functions-core-tools

我正在尝试从 VS 代码部署我的 azure 函数 (python),但出现以下错误。

我能够在我的本地机器上调试我的代码而没有任何错误,但我不明白为什么部署失败。

11:55:51 PM nhtsacleanse: Detecting platforms...
11:55:51 PM nhtsacleanse: Error: Oops... An unexpected error has occurred.
11:55:53 PM nhtsacleanse: /opt/Kudu/Scripts/starter.sh oryx build /tmp/zipdeploy/extracted -o /home/site/wwwroot --platform python --platform-version 3.7 -p packagedir=.python_packages/lib/site-packages
11:55:57 PM nhtsacleanse: Deployment failed.

enter image description here

在 azure 门户中创建了 azure 函数应用

enter image description here

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

根据我的经验,在VS代码中点击按钮部署函数有时可能会出现意外的错误信息。您可以使用命令 func azure functionapp publish <functionAppName> --build remote 来部署您的函数。

在 VS 代码中运行命令之前,您需要先在 azure 门户上创建一个函数应用。当您在门户上创建函数应用程序时(以避免版本问题),请选择如下屏幕截图所示的python 3.7,因为您本地的python函数似乎是3.7。然后在 VS 代码的“终端”窗口中运行命令,将代码从本地部署到 azure。我通常使用这种部署方法,并且总是很好。

enter image description here