Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please type your username.

Please type your E-Mail.

Please choose an appropriate title for the post.

Please choose the appropriate section so your post can be easily searched.

Please choose suitable Keywords Ex: post, video.

Browse

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Navigation

  • Home
  • About Us
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Contact Us
Home/ Questions/Q 322

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Latest Questions

Author
  • 62k
Author
Asked: November 25, 20242024-11-25T09:49:08+00:00 2024-11-25T09:49:08+00:00

Deploying Strapi to an Azure AppService

  • 62k

I have seen a lot of people have issues deploying a Strapi JS application on Azure AppServices. It is not an intuitive process to say the least. In this post, we'll walk through the challenges and configurations necessary to deploy Strapi on Azure AppServices.

AppService Configuration

The following sections will discuss the changes needed to modify the Azure AppService deployment process to work with Strapi.

The Deployment File

Azure AppServices will run some build steps during deployment. However, we can change the default process by including a .deployment file to the root of your Strapi project. This file works like a tells Azure what to do during deployment:

[config] SCM_DO_BUILD_DURING_DEPLOYMENT = false NODE_ENV = production COMMAND = bash deploy.sh 
Enter fullscreen mode Exit fullscreen mode

The counterpart to the .deployment file is the deploy.sh script, which orchestrates the deployment process. Create this file in the root of your application and include this snippet:

#! /bin/bash echo "Removing src, config" rm -rf /home/site/wwwroot/src rm -rf /home/site/wwwroot/config rsync -arv --no-o --no-g --ignore-existing --size-only  ./ /home/site/wwwroot echo "Source sync done." 
Enter fullscreen mode Exit fullscreen mode

This script ensures that any old, unwanted files are removed, preventing obsolete files from causing issues at runtime.

Node Version and Start Command

Azure needs to know which version of Node.js to use and how to get your application running. On the AppService's Configuration page, under the General Settings tab, make sure the Major and Minor versions are set to match Node 18 LTS or the latest version that Strapi supports.

You will also want to make sure your package.json scripts include the path to the strap.js file:

"start": "node node_modules/@strapi/strapi/bin/strapi.js start", "build": "node node_modules/@strapi/strapi/bin/strapi.js build", 
Enter fullscreen mode Exit fullscreen mode

Note: The node version is likely to change. Please refer to the latest Strapi and Azure documentation to select the correct version.

Disabling SCM/Oryx Builds

By default, Azure AppServices will run a build process with SCM/Oryx during deployment, but this isn't needed for the Strapi app since we provide a custom deployment script. Disable it by setting the following application settings:

ENABLE_ORYX_BUILD=false SCM_DO_BUILD_DURING_DEPLOYMENT=false 
Enter fullscreen mode Exit fullscreen mode

Disabling node_modules Compression

Microsoft updated AppServices to include a feature that will zip the node_modules folder and move it to the local container file system. This does provide a performance improvement for more applications. However, Strapi doesn't play nicely with the way Azure zips and relocates the node_modules folder. You will need to disable this feature to avoid issues with Strapi, disable this feature by updating this application setting:

BUILD_FLAGS=Off 
Enter fullscreen mode Exit fullscreen mode

More information about Oryx and Node.js can be found here.

Optional: Extend Container Startup Time

If your Strapi application is taking too long to start, you might want to increase the amount off time Azure will wait for the container to start. Update the following application setting if needed:

WEBSITES_CONTAINER_START_TIME_LIMIT=1600 
Enter fullscreen mode Exit fullscreen mode

GitHub Action Configuration

To enable automated deployments you will need to set up a GitHub action to package the Strapi application for Azure AppServices. This is pretty standard for a Node.js application but let's review a few important details.

Specify Node.js Version

Ensure you're using the correct version of Node.js in your GitHub action workflow:

steps:   - uses: actions/checkout@v3    - name: Set up Node.js version     uses: actions/setup-node@v3     with:       node-version: 18 
Enter fullscreen mode Exit fullscreen mode

Note: The node version is likely to change. Please refer to the latest Strapi and Azure documentation to select the correct version.

Build and Zip Strapi

These steps will install the necessary node modules and run the Strapi build process. Once those are done, the next step will create a zip file containing all the application, including the .build and node_modules folders. It then uploads the zip file to GitHub artifacts.

- name: npm install, build, and test   env:       NODE_ENV: production   run: |       npm install       npm run build  - name: Create Archive of application code   run: |       mkdir -p zip       zip  -r zip/app.zip . -x@.zipignore  - name: Upload artifact for deployment job   uses: actions/upload-artifact@v3   with:       name: dimm-city-data       path: zip/app.zip 
Enter fullscreen mode Exit fullscreen mode

Don't forget to use a .zipignore file to exclude unnecessary files from the zip. Create the file in the root of the application and include these entries:

.editorconfig .env* .eslint* .git/* .github/* .gitignore .strapi-updater.json .tmp/* .vscode/* .zipignore README.md tools/* zip/* 
Enter fullscreen mode Exit fullscreen mode

Wrapping Up

Deploying Strapi on Azure AppServices can be a bit challenging. Knowing which settings to adjust can take some trial and error until you wrap your head around the Azure deployment process. Hopefully this guide helps make the deploying your Strapi application to Azure a little less daunting.

Here are a few links for additional information:

  • Official Strapi Documentation for Azure Deployment
  • Strapi Forum Discussions on Azure Deployment

Please feel free to post any questions or comments you have below, or reach out on social media.

Happy coding!

azuredevopsstrapiwebdev
  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question

Stats

  • Questions 4k
  • Answers 0
  • Best Answers 0
  • Users 1k
  • Popular
  • Answers
  • Author

    How to ensure that all the routes on my Symfony ...

    • 0 Answers
  • Author

    Insights into Forms in Flask

    • 0 Answers
  • Author

    Kick Start Your Next Project With Holo Theme

    • 0 Answers

Top Members

Samantha Carter

Samantha Carter

  • 0 Questions
  • 20 Points
Begginer
Ella Lewis

Ella Lewis

  • 0 Questions
  • 20 Points
Begginer
Isaac Anderson

Isaac Anderson

  • 0 Questions
  • 20 Points
Begginer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore, ask, and connect. Join our vibrant Q&A community today!

About Us

  • About Us
  • Contact Us
  • All Users

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Help

  • Knowledge Base
  • Support

Follow

© 2022 Querify Question. All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.