title: Import module into Python Azure Function
body: <p>I'm trying to make a simple Azure Function that receives an HTTP event, grabs a JSON object in the body of that request, and saves that object as a document in a CosmosDB collection. I seem to be getting hung up on importing a python module however.</p>
  
  <p><strong>__init__.py</strong></p>
  
  <pre><code>import json
  import azure.functions as func
  import azure.cosmos.cosmos_client as cosmos_client
  
  
  config = {
    'ENDPOINT': 'https://XXXXXX.documents.azure.com:443/',
    'PRIMARYKEY': 'XXXXXX',
    'DATABASE': 'my-database',
    'CONTAINER': 'my-container'
  }
  
  def main(req: func.HttpRequest) -&gt; func.HttpResponse:
    try:
      client = cosmos_client.CosmosClient(config['ENDPOINT'], {'masterKey': config['PRIMARYKEY']})
      results = req.get_json()
  
      client.get_database_client(config['DATABASE']).get_container_client(config['CONTAINER']).upsert_item(results)
  
      return func.HttpResponse("Success", status_code=200)
    except ValueError:
      return func.HttpResponse("Please pass a JSON object", status_code=400)
  </code></pre>
  
  <p><em>Error Log</em></p>
  
  <pre><code>019-07-11T22:51:22.613140092Z: [INFO]  Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: Functions.save-to-cosmos ---&gt; Microsoft.Azure.WebJobs.Script.Rpc.RpcException: Result: Failure
  2019-07-11T22:51:22.616516971Z: [INFO]  Exception: ModuleNotFoundError: No module named 'azure.cosmos'
  2019-07-11T22:51:22.616547173Z: [INFO]  Stack:   File "/usr/local/lib/python3.6/site-packages/azure/functions_worker/dispatcher.py", line 230, in _handle__function_load_request
  2019-07-11T22:51:22.632613023Z: [INFO]      func_request.metadata.entry_point)
  2019-07-11T22:51:22.632631824Z: [INFO]    File "/usr/local/lib/python3.6/site-packages/azure/functions_worker/loader.py", line 66, in load_function
  2019-07-11T22:51:22.632637524Z: [INFO]      mod = importlib.import_module(fullmodname)
  2019-07-11T22:51:22.632641725Z: [INFO]    File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
  2019-07-11T22:51:22.632646025Z: [INFO]      return _bootstrap._gcd_import(name[level:], package, level)
  2019-07-11T22:51:22.632650325Z: [INFO]    File "&lt;frozen importlib._bootstrap&gt;", line 994, in _gcd_import
  2019-07-11T22:51:22.632655025Z: [INFO]    File "&lt;frozen importlib._bootstrap&gt;", line 971, in _find_and_load
  2019-07-11T22:51:22.632660926Z: [INFO]    File "&lt;frozen importlib._bootstrap&gt;", line 941, in _find_and_load_unlocked
  2019-07-11T22:51:22.632682827Z: [INFO]    File "&lt;frozen importlib._bootstrap&gt;", line 219, in _call_with_frames_removed
  2019-07-11T22:51:22.632688427Z: [INFO]    File "&lt;frozen importlib._bootstrap&gt;", line 994, in _gcd_import
  2019-07-11T22:51:22.632692727Z: [INFO]    File "&lt;frozen importlib._bootstrap&gt;", line 971, in _find_and_load
  2019-07-11T22:51:22.632697128Z: [INFO]    File "&lt;frozen importlib._bootstrap&gt;", line 955, in _find_and_load_unlocked
  2019-07-11T22:51:22.632723529Z: [INFO]    File "&lt;frozen importlib._bootstrap&gt;", line 665, in _load_unlocked
  2019-07-11T22:51:22.632729029Z: [INFO]    File "&lt;frozen importlib._bootstrap_external&gt;", line 678, in exec_module
  2019-07-11T22:51:22.632733329Z: [INFO]    File "&lt;frozen importlib._bootstrap&gt;", line 219, in _call_with_frames_removed
  2019-07-11T22:51:22.632737430Z: [INFO]    File "/home/site/wwwroot/save-to-cosmos/__init__.py", line 3, in &lt;module&gt;
  2019-07-11T22:51:22.632741830Z: [INFO]      import azure.cosmos.cosmos_client as cosmos_client
  </code></pre>
  
  <p>I have tried going through Kudu like this question suggested <a href="https://stackoverflow.com/questions/38965193/importing-python-modules-for-azure-function">Importing Python modules for Azure Function</a> and tried running <code>pip install azure-cosmos</code> but that doesn't seem to fix the problem.</p>