AZ-204 Develop Azure compute solutions Practice Question
You are deploying an application to Azure App Service that requires a custom startup script to initialize the environment. Where should you place the startup script in the application code?
⚠ Common exam trap
Many exam-takers assume placing a script file in the application root is sufficient for execution, but Azure App Service requires explicit configuration to designate a startup file or command, as the platform does not automatically scan for or execute arbitrary scripts.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
As a startup command in the App Service configuration
Azure App Service allows you to specify a custom startup command or script in the App Service configuration (under 'General settings' or via the Azure CLI with `--startup-file`). This startup command runs before the application starts, enabling you to initialize the environment, run pre-deployment tasks, or set up dependencies. Placing the startup script in the configuration ensures it is executed by the App Service platform, which handles the runtime environment (Windows or Linux) and integrates with the application lifecycle.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
In the 'web.config' file
Why it's wrong here
The 'web.config' file is specific to Internet Information Services (IIS) and ASP.NET applications, primarily used for configuring handlers, modules, and application settings within that environment. It is not a general mechanism for defining arbitrary startup scripts or commands for an Azure App Service instance, especially for non-Windows or non-.NET runtimes. Attempting to define a shell script or custom startup logic here would be ineffective for the App Service platform's startup process.
- ✗
In a 'docker-compose.yml' file
Why it's wrong here
A 'docker-compose.yml' file is designed for defining and running multi-container Docker applications, orchestrating services, networks, and volumes. While Azure App Service supports single-container Docker deployments, it does not directly interpret 'docker-compose.yml' for configuring the startup command of a single App Service instance. For multi-container scenarios, Azure Container Apps or Azure Kubernetes Service (AKS) would be more appropriate platforms, as App Service's container support focuses on individual container images.
- ✗
In the root of the application code as 'startup.sh'
Why it's wrong here
Simply placing a file named 'startup.sh' in the root of the application code does not automatically instruct Azure App Service to execute it upon deployment or instance startup. Azure App Service requires an explicit configuration setting to specify the command or script that should be run when the application initializes. Without this explicit configuration, the 'startup.sh' file would be deployed but remain unexecuted by the platform's startup process.
- ✓
As a startup command in the App Service configuration
Why this is correct
Azure App Service provides a dedicated configuration setting to specify the exact command or script that should be executed when the application instance starts. This can be configured through the Azure portal under 'Configuration' -> 'General settings' -> 'Startup Command,' or programmatically via Azure CLI using `az webapp config set --startup-file`. This mechanism allows for executing custom shell scripts (e.g., `./startup.sh`) or direct application commands (e.g., `npm start`, `gunicorn app:app`) to properly initialize the application environment.
Go deeper
Related to this question
About these practice questions
Courseiva writes every AZ-204 question from scratch — 881 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This AZ-204 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AZ-204 exam.