Speed Up Your Azure Web App Deployment with WEBSITE_RUN_FROM_PACKAGE

Devops | 3x AWS Certified | CKA
Search for a command to run...

Devops | 3x AWS Certified | CKA
No comments yet. Be the first to comment.
Introduction If you are moving to AWS Identity Center (formerly SSO) and want to keep your Google Workspace users and groups in sync, ssosync is the go-to tool. However, setting up the permissions can be tricky. If you’ve seen the error unauthorized_...

Introduction In this tutorial, I will guide you through establishing a SAML connection between Google Workspace and AWS Identity Center. Later, you will synchronize users from Google Workspace using SCIM. To verify that everything is configured corre...

Implementing Gang Scheduling for Distributed GPU Training on Amazon EKS

General DevOps logic behind jiocinema

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.
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.
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.
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.
WEBSITE_RUN_FROM_PACKAGE1: 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_PACKAGE to 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.
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
Upload the Package
Set the WEBSITE_RUN_FROM_PACKAGE Setting
az webapp config appsettings set --resource-group <group-name> --name <app-name> --settings WEBSITE_RUN_FROM_PACKAGE=1
Replace <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
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 : )