0

Good morning, I'm trying to build and deploy an azure functions python in linux with python 3.7, following the steps in https://learn.microsoft.com/en-us/azure/azure-functions/functions-how-to-azure-devops?tabs=python and I get the following error: ModuleNotFoundError: No module named 'azure.cosmosdb', I am using an App Service Plan Basic. I tried this same azure function with consumption and it works correctly for me I need to install wkhtmltopdf with which consumption does not work for me, when creating the azure function with App Service Plan Basic it does not get the module and all the functions and environment are created.

I have tried to do the manual deploy via visual studio code and via azure devops and I get the same result from modulenotfound.

  • I found some similar issues, [link1](https://github.com/Azure/azure-functions-python-worker/issues/477) and [link2](https://github.com/Azure/azure-functions-python-worker/issues/617) you could check if it can give you some help, If the issue still occurs, could you please share the detail log in the issue description? – Vito Liu Aug 12 '20 at 06:17
  • Hi Wallys, could you please share the latest debug log here? – Vito Liu Aug 28 '20 at 10:19

1 Answers1

0

The solution is add the modules that required to requirements.txt.

(Python azure function is based on this file to install module. pip or other method will not work. When you deploy, the tools will pack all modules by requirements.txt.)

Your requirements.txt should be like this:

azure-functions
azure.cosmosdb=xx.xx
Cindy Pau
  • 13,085
  • 1
  • 15
  • 27
  • Hello, the azure cosmosdb modules are specified in the requirement.txt azure-cosmosdb-nspkg == 2.0.2 azure-cosmosdb-table == 1.0.6 As I mentioned earlier, it works in Serverless plan, install its dependencies from the file requirement.txt. When I switch to a Basic plan, it doesn't read the dependency. Try pip install --target = " /.python_packages/lib/site-packages" -r requirements.txt and it didn't work either. It only works from Serverless and Azure Functions Container. – Wallys Alexander Morales Gonza Aug 18 '20 at 13:37