During my recent internship at Arinti I learned a few useful things about the combination of Python and Azure. The Azure SDK for Python is composed of many individual libraries. With these libraries you can provision and manage resources on Azure services (using the management libraries) and connect with those resources from app code (using the client libraries). I used these to build a nifty tool that can turn sketches and drawings of electrical schema’s into digital versions, recognizing certain components & parts of the drawing. In this blog I will show you one way to install modules in a Python Azure function. As an example we will use OpenCV and NumPy as modules.
In VS Code go to the marketplace to download the extension Azure functions and Azure Account.
Now sing up or create a new Azure account in Azure Functions.
Click on create a new function choose Python and choose your Python environment.
Then choose your trigger. In this example we’ll use the HTTP trigger. Next, choose a name for your project and choose for an anonymous authorization level.
When your project is created click on terminal, then new terminal. Then in the terminal type “pip install opencv-python numpy”.
And that’s it! Now you should be able to use your Azure Function locally. You will be able to deploy it on Azure, but in some cases you will still get an error because OpenCV and NumPy are just installed locally and not on Azure.
Thanks for reading!