Recently, I jumped on the serverless hype train. I basically sold my soul to Microsoft and Azure, so the possibility of running Python in Azure Functions is pretty damn cool. But since it’s still in preview mode (beta), it has proven to be a nerve-wrecking experience.
Here’s some brief instructions on getting started in Azure, using Visual Studio Code.
- Download and Install Python (3.6.8)
- Download and install .NET Core SDK
- Download and install VS Code
- Download and install node.js or chocolatey
- Download and install Azure Core Tools (replace npm with choco if you installed chocolatey)
- Download and install Azure CLI
- Run the following command in PowerShell in Admin Mode: install -g azure-functions-core-tools
- Run the following command in PowerShell in Admin Mode: Set-ExecutionPolicy unrestricted
- Install the VS Code Azure Functions extension
- Install Docker
By clicking the lightning in VS Code, it will basically automate the boring stuff for you. A new virtual environment will be created and your first function — with example code — will be created locally.
Furthermore, by following these instructions, creating a functions project in Azure is piece of cake.
However, if you want to use unsupported packages that need to be installed, there’s a not so pleasant surprise. Not even Microsoft own Azure packages are supported. You will run into the following error: “There was an error restoring dependencies.ERROR: cannot install <package name – version> dependency: binary dependencies without wheels are not supported. The terminal process terminated with exit code: 1”
For days I have been looking for an elegant solution, but there is none. The only workaround is by using Docker. Although VS Code will do the hard work for you, you still need to have it installed. Then you can publish your function to Azure by using the following PowerShell command:
func azure functionapp publish <name> --build-native-deps