2

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?

wwnde
  • 26,119
  • 6
  • 18
  • 32

1 Answers1

1

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.

Hury Shen
  • 14,948
  • 1
  • 9
  • 18
  • ShenThanks for the prompt reply. Where do I run this requirement in Azure-kudus -SSH? or in VSC Terminal? – wwnde Nov 04 '20 at 05:38
  • Hi @wwnde You do not need to run `requirements.txt` in azure kudu. You just need to run `pip freeze > requirements.txt` in VSC terminal to add all of the modules into `requirements.txt` and when you deploy the function to azure portal, it will install the modules according to the content of `requirements.txt` automatically. – Hury Shen Nov 04 '20 at 05:40
  • @wwnde You can refer to this [post](https://stackoverflow.com/questions/61975311/how-to-install-python-module-in-azure-function-linux-app/61998041#61998041) which is similar to your problem. – Hury Shen Nov 04 '20 at 05:41
  • I did run the requirements.txt it is step 3 in the post I am having issues with. Where do I get that done? – wwnde Nov 04 '20 at 05:43
  • I mean where do I run `func azure functionapp publish --build remote` tried that in the terminal and `The system cannot find the file specified.` – wwnde Nov 04 '20 at 05:45
  • @wwnde Ok, please try to deploy the function to azure cloud by the way you used before. – Hury Shen Nov 04 '20 at 05:47
  • @wwnde I think the `requirements.txt` is the key, it doesn't matter in which deploy way. – Hury Shen Nov 04 '20 at 05:48
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/224074/discussion-between-wwnde-and-hury-shen). – wwnde Nov 04 '20 at 05:53