In August Microsoft announced that Python support in Azure Functions was Generally Available (GA), meaning it was ready for use for production scenarios.
In this post I'll take a quick look at how you can quickly deploy Python Functions using Azure Pipelines which is a part of Azure DevOps.
Build and package
You now have the choice to package Python Azure Functions using a pre-built template in Azure Pipelines.
Once you select this you will have all you need to restore any Python modules you have in your requirements.txt file and ensure any Azure Function Extensions are also installed. The resulting footprint is then zipped for use in a release.
If, like me, you put multiple independent Azure Functions into a single Azure Git Repo then you will need to modify three of the build Tasks to ensure you have the sub-folder selected when running commands.
First we need to ensure we restore the Azure Functions Extensions so we'll add a 'cd' command in and switch into the right folder.
Then we have make sure we restore Python modules based on the
requirements.txt in the subfolder.
Finally we need to edit the Archive Files Task ensure you select the same sub-folder as the previous step.
Right, if you run this build you'll end up with a zip file ready to deploy.
Releasing into Azure
We can now create an Azure Pipelines Release that uses the standard Azure Function template (shown below). There are no special steps to use as you are deploying into a host environment already setup for Python Functions.
Once you run the Release your Function is deployed! If you need to deploy App Settings at the same time you can use the 'Application and Configuration Settings' section of the 'Deploy Azure Function App' Task to specify the settings to deploy.
That's it - so much easier than when this capability was all in preview!