Azure Functions with Pythonの落とし穴

## 経緯

[自作ライブラリを`.python_packages/lib/site-packages`にインストールする方法](https://docs.microsoft.com/ja-jp/azure/azure-functions/functions-reference-python?tabs=azurecli-linux%2Capplication-level#install-local-packages)が紹介されていた。
非公開のPythonライブラリを使用したかったので、この方法を試したが憂き目にあった。

### 環境
以下の環境で進めた。Pythonは3.7.9とする。

```bat
> func --version
3.0.3568
>pip list | findstr azure-cli
azure-cli                               2.28.0
azure-cli-core                          2.28.0
azure-cli-telemetry                     1.0.6
```

### 事象：Numpyがビルドされない

Azure Functions AppにPython製のプログラムを`func azure functionapp publish <MY_APP_NAME> --no-build`したら`numpy`がうまくビルドされなかった。上述`.python_packages`を使う方法のときは、`publish`の際に`--no-build`オプションをつけろと指示があったが、`--no-build`してしまうとnumpyがうまく入らない。（numpyはC言語で一部書かれているので、おそらく実行環境中のCコンパイラでビルドしないとうまく動作しないのだろう）

```csharp
Result: Failure Exception: ImportError: IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE! Importing the numpy C-extensions failed. This error can happen for many reasons, often due to issues with your setup or how NumPy was installed.
We have compiled some common reasons and troubleshooting tips at: https://numpy.org/devdocs/user/troubleshooting-importerror.html Please note and check the following: 
The Python version is: Python3.7 from "/usr/local/bin/python" * The NumPy version is: 
"1.21.2" and make sure that they are the versions you expect. Please carefully study the documentation linked above for further help. Original error was: No module named 'numpy.core._multiarray_umath' . 
Troubleshooting Guide: https://aka.ms/functions-modulenotfound Stack:
  File "/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/dispatcher.py", line 309, in _handle__function_load_request func_request.metadata.entry_point)
  File "/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 42, in call raise extend_exception_message(e, message)
  File "/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 40, in call return func(*args, **kwargs)
  File "/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/loader.py", line 83, in load_function mod = importlib.import_module(fullmodname) 
  File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) 
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import 
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load 
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked 
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/site/wwwroot/HttpTrigger/__init__.py", line 2, in <module> import tabula
  File "/home/site/wwwroot/.python_packages/lib/site-packages/tabula/__init__.py", line 3, in <module> from .io import convert_into, convert_into_by_batch, read_pdf, read_pdf_with_template 
  File "/home/site/wwwroot/.python_packages/lib/site-packages/tabula/io.py", line 30, in <module> import numpy as np 
  File "/home/site/wwwroot/.python_packages/lib/site-packages/numpy/__init__.py", line 150, in <module> from . import core File "/home/site/wwwroot/.python_packages/lib/site-packages/numpy/core/__init__.py", line 48, in <module> raise ImportError(msg)
```

## 解決策

<APP>フォルダにライブラリをフォルダとして保存する。[ドキュメント](https://docs.microsoft.com/ja-jp/azure/azure-functions/bring-dependency-to-functions?pivots=programming-language-python#bring-in-dependencies-from-the-project-directory)では以下のように`dependencies.dependency1`モジュールを追加する例が書いてある。この方法で無事に自作ライブラリをAzure Functions内で読み込むことができた。

```bash:筆者一部改変
<project_root>/
 | - my_first_function/
 | | - __init__.py
 | | - function.json
 | | - example.py
 | - dependencies/
 | | - dependency1.py
 | - .funcignore
 | - host.json
 | - local.settings.json
```