[英]debugging azure function locally with vscode and conda
there has been multiple articles online on how to run somewhat similar scenario.网上有多篇关于如何运行类似场景的文章。
I have tried following and nothing works completely.我试过以下但没有任何效果。
issue is how launch.json calls "host start".问题是 launch.json 如何调用“主机启动”。 this command changes into whatever is the value of "azureFunctions.pythonVenv" and then append " /Scripts/activate ".
此命令更改为“azureFunctions.pythonVenv”的值,然后更改为 append“ /Scripts/activate ”。
now the issue is.现在的问题是。
if i am using conda inside vscode, which creates ".conda" folder inside my workspace.如果我在 vscode 中使用 conda,它会在我的工作区中创建“.conda”文件夹。 this particular conda is missing "activate" file so command fails.
这个特定的 conda 缺少“激活”文件,因此命令失败。
if i use conda at machine level, it works, but it starts conda with environment as "base".如果我在机器级别使用 conda,它可以工作,但它以环境作为“基础”启动 conda。 there is no way i can change the environment inside "task.json", which type is "func"
我无法更改“task.json”中的环境,类型为“func”
i can change type of task from "func" to "shell", and then i can activate required env in conda, and azure function runs too.我可以将任务类型从“func”更改为“shell”,然后我可以在 conda 中激活所需的环境,并且 azure function 也运行。 but it doesn't go into debug mode.
但它不会 go 进入调试模式。 it just gives connection error for:9091.
它只是给出连接错误:9091。
After burning multiple days on this issue.在这个问题上燃烧了多天之后。 I can say that VSCODE + conda (not base) + AzureFunction + Debug doesnt work.
我可以说 VSCODE + conda(不是基础)+ AzureFunction + Debug 不起作用。
this is a pain.这是一个痛苦。 once you have multiple programs on your local machine, you lost any benefit conda provides.
一旦你的本地机器上有多个程序,你就失去了 conda 提供的任何好处。
Currently i am using option 2, as it atleast let me debug, which is a big deal for me.目前我正在使用选项 2,因为它至少让我调试,这对我来说很重要。
and again, everything works fine, if I just want to run AzureFunction, multiple ways to do that.再一次,一切正常,如果我只想运行 AzureFunction,有多种方法可以做到这一点。 But issue comes when i have to use conda (particular environment).
但是当我必须使用 conda(特定环境)时,问题就来了。
config that worked, with using base conda.使用基本 conda 的有效配置。
tasks.json任务.json
{
"version": "2.0.0",
"tasks": [
{
"label": "pipInstall",
"type": "shell",
"windows": {
"command": [
"conda.bat activate && pip install -r requirements.txt"
]
},
"problemMatcher": []
},
{
"type": "func",
"label": "func: host start",
"command": "host start",
"problemMatcher": "$func-python-watch",
"isBackground": true,
"dependsOn": ["pipInstall"]
}
]
}
settings.json (both settings may be a overkill, but its ok. settings.json(这两个设置可能有点矫枉过正,但没关系。
"python.defaultInterpreterPath": "C:XXXXXXXXX\\Miniconda3\\python.exe",
"azureFunctions.pythonVenv": "C:XXXXXXXXXXX\\Miniconda3",
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.