TimeTrigger Azure Function gives No Module Error in Azure Portal but runs well in VSC

Viewed 111

I successfully have created an Azure Time Trigger in Visual Studio Code.

I tested it in VSC before uploading onto Azure portal and it ran ok

enter image description here

When I run it in Azure though, it gives me an error no module named; enter image description here

I have gone back to try and install modules in the.venv and the modules exist.

How can I have this resolved?

1 Answers

The function on azure cloud will install the modules according to the requirements.txt. So when you deploy the function from local to azure portal, the modules which installed on local will not also be installed on azure cloud if you didn't add the modules to requirements.txt. You can run the command below to add all of the modules into requirements.txt automatically:

pip freeze > requirements.txt

And then run func azure functionapp publish <funciton app name on azure> --build remote to deploy the function from local to azure.

Related