For Squarl, I started to implement a couple of improvements for the back-end running on Azure Functions. I created these functions with TypeScript. In the past, I used webpack and later Azure Funcpack to bundle my functions to one file per function. That way, the host does not have to do all those read actions for retrieving the dependencies.
As I wanted to do the same thing, I read using Azure Funcpack is not supported/maintained anymore. Instead, you should use the run from package functionality.
What is the run from package option?
Instead of bundling, you install your dependencies, build your solution, and compress the directory as a ZIP file.
No significant changes, but now comes the cool part. The ZIP package gets used by the Azure Functions to run the function’s logic. Instead of pushing your files to the
wwwroot directory, the app service loads the ZIP package as a virtual directory.
This option improves the load times, deployment times, and more.
If you want to use this functionality, you will have to set the
WEBSITE_RUN_FROM_PACKAGE setting on your function app.
The value for this can refer to where the function app can find the ZIP package, or it can just be
1. This option is the recommended approach when running apps on Windows.
1 as the value, the function app will run the data from a local package. The ZIP package needs to be deployed to
d:\home\data\SitePackages as this improves the cold-start.
Info You can read more at: run your Azure Functions from a package file
How do you use it on GitHub Actions?
Important Make sure to first set the
1in the function app configuration.
The steps which you need to perform to deploy your code to the functions app are the following:
- Check out your code
- Specify the Node.js version to use
- Install your dependencies
- Build your project
- Create the ZIP
- Perform the deployment with the
My GitHub Actions workflow looks as follows:
Once this workflow ran. Your function app will now run from the package you deployed. You can verify this if you take a look in the
wwwroot directory. This directory should now contain the files from the package. Be aware; this directory is now read-only.
packagename.txtfile contains the name of the ZIP package which needs to be used.