You deploy a Node.js app on Linux App Service using the built-in runtime. Before the app starts, you must run database migrations, then launch the app with a custom command. How should you configure startup so this sequence runs on every app start?
Choose an answer
Tap an option to check your answer.
Correct answer: Add a bash script (e.g., /home/site/wwwroot/startup.sh) with a shebang, run migration commands, then start Node; make the script executable., In Configuration, set the Linux Startup Command to the full path of your startup script (e.g., /home/site/wwwroot/startup.sh)..
Why this is the answer
To run pre-startup commands like database migrations and then launch a Node.js app with a custom command on Azure App Service for Linux, the most effective method is using a custom startup script. You would create a bash script (e.g., startup.sh) in your application's root directory (/home/site/wwwroot/), ensuring it has a shebang (e.g., !/bin/bash) and execute permissions (chmod +x startup.sh). This script would contain your migration commands followed by the command to start your Node.js application. Then, in the App Service Configuration settings, you specify this script's full path (e.g., /home/site/wwwroot/startup.sh) in the "Startup Command" field. App Service will execute this script every time the container starts. Incorrect options: web.config is used for Windows App Service with IIS, not Linux App Service. WEBSITERUNFROMPACKAGE is for running an app directly from a deployment package (e.g., a zip file) and does not automatically handle pre-startup migrations. "Always On" keeps the app loaded to prevent cold starts but doesn't define custom startup logic or execute commands before the application process begins.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed