📖 Scenario: You are setting up a web application in Azure. To make your app work correctly, you need to store some important information like application settings and connection strings securely. These settings tell your app how to connect to databases and other services.
🎯 Goal: Build an Azure App Service configuration with application settings and connection strings defined in a JSON format. This configuration will be used to deploy the app with the correct environment variables.
📋 What You'll Learn
Create a JSON object for app settings with exact keys and values
Add a connection strings section with a named connection string
Use correct Azure App Service configuration structure
Ensure the JSON is valid and deployable
💡 Why This Matters
🌍 Real World
Storing app settings and connection strings securely is essential for cloud apps to connect to databases and services without hardcoding sensitive info.
💼 Career
Cloud engineers and DevOps professionals often create and manage these configurations to ensure apps run correctly and securely in Azure.
Progress0 / 4 steps
1
Create the application settings section
Create a JSON object called appSettings with these exact key-value pairs: "ENVIRONMENT": "Production" and "LOG_LEVEL": "Warning".
Azure
Hint
Use a JSON object with keys and string values inside appSettings.
2
Add the connection strings section
Add a JSON object called connectionStrings with one entry named DefaultConnection having the value "Server=myserver;Database=mydb;User Id=myuser;Password=mypassword;".
Azure
Hint
Place the connection string inside connectionStrings as a key-value pair.
3
Wrap settings in Azure App Service configuration format
Wrap the existing appSettings and connectionStrings inside a top-level JSON object with the key properties.
Azure
Hint
Put both appSettings and connectionStrings inside properties.
4
Add the slot setting flag to connection strings
Inside connectionStrings, add a nested object for DefaultConnection with keys value set to "Server=myserver;Database=mydb;User Id=myuser;Password=mypassword;" and slotSetting set to true.
Azure
Hint
Use an object for DefaultConnection with value and slotSetting keys.
Practice
(1/5)
1. What is the main purpose of using Application settings in an Azure App Service?
easy
A. To store configuration values separately from the app code
B. To write application code directly in the Azure portal
C. To deploy the app to multiple regions automatically
D. To monitor app performance metrics
Solution
Step 1: Understand what application settings are
Application settings hold configuration values like API keys or feature flags outside the app code.
Step 2: Identify the benefit of separation
Separating settings allows changing them without redeploying or modifying the app code.
Final Answer:
To store configuration values separately from the app code -> Option A
Quick Check:
Application settings separate config from code [OK]
Hint: Settings keep config outside code for easy updates [OK]
Common Mistakes:
Confusing settings with code deployment
Thinking settings are for monitoring
Assuming settings are for writing code
2. Which Azure CLI command correctly sets an application setting named MySetting with value Value123 for an App Service named MyApp?
easy
A. az webapp config appsettings set --name MyApp --resource-group MyGroup --settings MySetting=Value123
B. az webapp create appsettings add --name MyApp --settings MySetting=Value123
C. az appservice config set --app MyApp --setting MySetting=Value123
D. az webapp config connection-string set --name MyApp --settings MySetting=Value123
Solution
Step 1: Identify the correct Azure CLI command for app settings
The command to set app settings is az webapp config appsettings set with parameters for app name, resource group, and settings.
Step 2: Check the syntax for setting a key-value pair
The settings parameter uses key=value format, here MySetting=Value123.
Final Answer:
az webapp config appsettings set --name MyApp --resource-group MyGroup --settings MySetting=Value123 -> Option A
Quick Check:
Use az webapp config appsettings set with key=value [OK]
Hint: Use 'az webapp config appsettings set' with key=value [OK]
Common Mistakes:
Using wrong command verbs like create or add
Confusing app settings with connection strings
Missing resource group parameter
3. Given this Azure CLI command output after setting a connection string:
What will the app receive when accessing the connection string DbConn?
medium
A. An empty string because connection strings are not set this way
B. An error because the connection string type is missing
C. The string 'Server=myserver;Database=mydb;' as the connection string value
D. The connection string encrypted and unreadable
Solution
Step 1: Understand the connection string format in Azure
The output shows a connection string named 'DbConn' with a valid connection string value and type 'SQLAzure'.
Step 2: Determine what the app receives
The app reads the connection string value as plain text 'Server=myserver;Database=mydb;' to connect to the database.
Final Answer:
The string 'Server=myserver;Database=mydb;' as the connection string value -> Option C
Quick Check:
Connection strings provide plain text values to apps [OK]
Hint: Connection strings deliver plain text values to apps [OK]
Common Mistakes:
Assuming connection strings are encrypted automatically
Thinking type field is mandatory for usage
Believing connection strings are empty if not set in code
4. You run this Azure CLI command to update an app setting: az webapp config appsettings set --name MyApp --resource-group MyGroup --settings MySetting But it fails with an error. What is the likely cause?
medium
A. The resource group name is incorrect
B. The setting value is missing after the key 'MySetting'
C. The app name 'MyApp' does not exist
D. The command should use 'appsettings add' instead of 'set'
Solution
Step 1: Check the command syntax for setting app settings
The --settings parameter requires key=value pairs, but only 'MySetting' (key) is provided without a value.
Step 2: Identify the error cause
Missing value after the key causes the command to fail due to invalid syntax.
Final Answer:
The setting value is missing after the key 'MySetting' -> Option B
Quick Check:
App settings need key=value pairs [OK]
Hint: Always provide key=value pairs for app settings [OK]
Common Mistakes:
Omitting the value after the key
Assuming 'set' is wrong command
Ignoring error messages about syntax
5. You want to securely update a database connection string in your Azure App Service without restarting the app. Which approach is best?
hard
A. Edit the connection string directly in the app code and redeploy
B. Set the connection string as an environment variable in your local machine
C. Store the connection string in a public GitHub repo and pull it at runtime
D. Use Azure CLI to update the connection string via az webapp config connection-string set and enable slot settings