question

PrasadRakesh-7935 avatar image
0 Votes"
PrasadRakesh-7935 asked CharlesGOSSELIN-1735 edited

running azure function locally (conda)

hi,

I am trying to run azure function locally.

I want to use conda python for it. And I do not want to set python path at system level. (i have 4-5 python projects each using different conda environment).

function runs fine in Azure. My question is can i run it locally with conda?

my build process run fine, as settings.json and tasks.json can take python path as argument. and I am able to run it with one specific environment of conda.

but it seems launch is having an issue. how can i resolve it? 74160-azure-function-local-run.png

i am getting error as =>

 > Executing task: func host start <
    
 Could not find a Python version. Python 3.6.x, 3.7.x, 3.8.x or 3.9.x is recommended, and used in Azure Functions.
 The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command func host start" terminated with exit code: 1.


azure-functions
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@PrasadRakesh-7935 Based on the error, looks like func is running in a new PowerShell prompt instead of directly in the current shell. Could you share your launch.json and tasks.json?

0 Votes 0 ·

any guidance? i have posted all 3 files.

0 Votes 0 ·

1 Answer

CharlesGOSSELIN-1735 avatar image
0 Votes"
CharlesGOSSELIN-1735 answered CharlesGOSSELIN-1735 edited

Hello,

I have the same issue.

Did you solve yours ?

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

yes, kind of.

i am able to find by comparison. I just compared 2 projects. one working and one that stopped working.

only consistent difference was, missing ".venv" environment.

i tried searching web, on its significant, how to restore it? or how to create one, if it went missing.

I was not able to find anything on it. So I created new project from start and just got my assets(files) in new one.

0 Votes 0 ·

Oh yeah, it's the environment that is automatically generated when creating a new function using the Azure Function vs extension. It's a "vanilla" venv (created using python -m venv).
So it's not a real conda one.

On my side I gave up. I cannot find a way to decently debug this thing using conda environment because it's always activating the venv described by the python.venv variable as a vanilla venv.
I do not think it's something we have hands on.

0 Votes 0 ·