【问题标题】:debug azure webapp using ssh使用 ssh 调试 azure webapp
【发布时间】:2022-11-04 15:45:54
【问题描述】:

我正在 azure cloud 中开发一个新的 webapp。

挑战在于我正在开发一个我不太了解的新 python 模块,Pyspice。 Pyspice 与程序 Ngpspice 的接口。 在我的 Windows PC 上它工作正常,但在云上却不行。所以我希望能够在不推送的情况下进行调试,然后为每个构建等待 25 分钟。

现在我正在使用 SSH 连接到 webapp。然后我可以创建一个简单的 python 脚本来查看是否可以在 pyspice 和 ngspice 之间建立连接。我面临的挑战是,当我在 SSH 中运行 python 时,它使用的环境与 webapp 不同,即 requirements.txt 中的所有模块都不可用。那么我怎样才能改变环境才能调试呢?

【问题讨论】:

  • SSH 和 Web App 中的 python 版本是什么?

标签: debugging ssh azure-web-app-service


【解决方案1】:

SSH中的python然后它使用与webapp不同的环境

我已经使用 Python 3.8 版创建了一个 Azure App 服务,当我在 Azure SSH 中检查版本时,它会显示不同的版本。

若要在 Azure SSH 中安装最新版本,请运行以下命令

apt update
apt install python3.9
python --version

运行以下命令以更改 Azure Cloud Shell (Bash) 中 Azure App 服务的 python 版本。

az webapp config set --resource-group MyRGName --name WebAppName --linux-fx-version "PYTHON|3.9"

要检查更新版本,请运行以下命令

az webapp config show --resource-group MyRGName --name  Python4Nov --query linuxFxVersion

使用 ssh 调试 azure webapp

要远程调试 Azure Linux App Service,我们需要打开从开发机器到 Azure App Service 的 TCP 隧道。

配置 SSH 和远程调试在 Azure CLI 中运行以下命令

az webapp create-remote-connection --resource-group MyRG -n WebAppName

参考来自MSDoc

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-17
    • 2020-02-03
    • 2016-08-26
    • 2016-04-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多