Home ยป Using Python in Azure Functions

Using Python in Azure Functions

  • by
Want to do a random act of kindness? Share this post.
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.

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
Good luck!
Want to do a random act of kindness? Share this post.