Speed Up Your Azure Web App Deployment with WEBSITE_RUN_FROM_PACKAGE

Devops | 3x AWS Certified | CKA
Quick Solution
If you're in a hurry to solve deployment time issues, simply add the
WEBSITE_RUN_FROM_PACKAGEenvironment variable to your Azure Web App settings and set its value to1. This change can significantly reduce your deployment times.
Why slow deployment in azure webapp ?
When deploying applications to Azure Web Apps without the WEBSITE_RUN_FROM_PACKAGE setting, the process typically involves:
Uploading Files: Your deployment pipeline uploads the application files to the Azure Web App.
Extracting Files: If the application is uploaded as a compressed package (like a ZIP file), the web app service extracts the contents to the file system.
Restarting the Web App: The web app might need to restart to pick up the new files.
File Synchronisation: The Azure Web App synchronises the new files with the existing file system.
Problems with Traditional Deployment
Long Deployment Times: Extracting and synchronising files can be slow, especially for large applications or many files.
File Corruption: There is a risk of file corruption during extraction or synchronisation.
Downtime: The web app might be unavailable during the file extraction and restart process, causing service disruption.
What WEBSITE_RUN_FROM_PACKAGE Does ?
The WEBSITE_RUN_FROM_PACKAGE setting simplifies the deployment process by running the application directly from a package file, such as a ZIP file. This eliminates the need to extract the files, reducing deployment times and potential issues.
Possible Values for WEBSITE_RUN_FROM_PACKAGE
1: This value tells Azure to run the web app directly from a package file that has been deployed. The app reads the package and executes it without extracting the contents.URL: You can also set
WEBSITE_RUN_FROM_PACKAGEto a URL pointing to a package file stored in Azure Blob Storage. This can be useful for scenarios where you manage your application packages in Blob Storage and want the web app to fetch the package directly from there.
How to Implement WEBSITE_RUN_FROM_PACKAGE ?
Here’s a step-by-step guide to implementing WEBSITE_RUN_FROM_PACKAGE in your deployment process:
Prepare Your Deployment Package
- Compress your application into a ZIP file. Ensure that the package contains all the necessary files for your application to run.
Upload the Package
- Use your CI/CD pipeline to upload the ZIP file to Azure. This can be done using Azure DevOps, GitHub Actions, or any other CI/CD tool you prefer.
Set the
WEBSITE_RUN_FROM_PACKAGESettingaz webapp config appsettings set --resource-group <group-name> --name <app-name> --settings WEBSITE_RUN_FROM_PACKAGE=1Replace
<group-name>and<app-name>with your resource group name and web app name.
Either do above step or simply add env in webapp manually from azure console
Example GitHub Actions Workflow
Here’s an example of how you can set up a GitHub Actions workflow to deploy your Node.js application using WEBSITE_RUN_FROM_PACKAGE:
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions
name: Build and deploy Node.js app to Azure Web App - my-webapp
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js version
uses: actions/setup-node@v3
with:
node-version: "20.x"
- name: npm install, build, and test
run: |
npm install
npm run build --if-present
- name: Zip artifact for deployment
run: zip release.zip ./* -r
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: node-app
path: release.zip
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: "Production"
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
permissions:
id-token: write #This is required for requesting the JWT
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
with:
name: node-app
- name: Unzip artifact for deployment
run: unzip release.zip
- name: Login to Azure
uses: azure/login@v1
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID }}
- name: "Deploy to Azure Web App"
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: "my-webapp"
slot-name: "Production"
package: .
Follow me on
LinkedIn : https://www.linkedin.com/in/akash202k/
Twitter : https://x.com/akash202k_
Thank You
Happy Learning : )



