AZ-204 Case Studies & Practical Application 3 — Questions and Answers
Question 1: A company's Azure Function uses a Storage Queue trigger. During a traffic spike, 50,000 messages arrive and the function scales out. Developers notice duplicate message processing. What is causing this and how should it be addressed?
- Queue Storage guarantees at-least-once delivery; use idempotent logic or track processed message IDs (Correct answer)
- Increase the visibilityTimeout in host.json to prevent other instances from seeing the message
- Switch to Event Grid trigger, which guarantees exactly-once delivery
- Set maxDequeueCount to 1 to prevent re-processing
Correct answer: Queue Storage guarantees at-least-once delivery; use idempotent logic or track processed message IDs
Azure Storage Queues guarantee at-least-once delivery, so duplicates are expected; the correct pattern is idempotent processing rather than relying on the queue for deduplication.
Question 2: A developer needs to implement a background job in an Azure Web App that runs every 15 minutes. The job must co-locate with the web app and share its environment variables. What is the simplest approach?
- Add a triggered WebJob with a CRON schedule set to '0 */15 * * * *' (Correct answer)
- Create a separate Azure Function App with a Timer trigger
- Use Azure Scheduler to POST to a web app endpoint every 15 minutes
- Deploy a second App Service instance running just the scheduled task
Correct answer: Add a triggered WebJob with a CRON schedule set to '0 */15 * * * *'
WebJobs run within the same App Service plan and share the app's settings, making them the simplest co-located scheduling option without provisioning additional resources.
Question 3: An application writes telemetry to Application Insights. In production, the volume is very high and costs are excessive. The developer wants to reduce data volume but retain all exceptions and slow requests. Which strategy should be applied?
- Configure adaptive sampling with a rule to exclude exceptions and dependency failures from sampling (Correct answer)
- Set a fixed sampling percentage of 10% on all telemetry types
- Disable Application Insights for performance counters only
- Use the Metrics stream instead of full telemetry logging
Correct answer: Configure adaptive sampling with a rule to exclude exceptions and dependency failures from sampling
Adaptive sampling intelligently reduces volume while allowing exclusion of critical telemetry types like exceptions, preserving diagnostic fidelity at lower cost.
Question 4: A developer is building an API secured by Azure AD. A client app must call the API on behalf of a signed-in user. Which OAuth 2.0 flow should be used?
- Authorization Code flow with PKCE (Correct answer)
- Client Credentials flow
- Device Code flow
- Resource Owner Password Credentials flow
Correct answer: Authorization Code flow with PKCE
Authorization Code flow with PKCE is the recommended flow for user-delegated access from a client app, providing both security and user context to the API.
Question 5: A retail app stores session state in Azure Cache for Redis. After a Redis failover, users are logged out. The developer wants sessions to survive failover. What should be configured?
- Enable Redis persistence (AOF or RDB) on a Premium tier cache (Correct answer)
- Switch to Azure SQL Database for session storage
- Use the Standard tier with geo-replication enabled
- Set the session cookie expiry to a longer value
Correct answer: Enable Redis persistence (AOF or RDB) on a Premium tier cache
Redis persistence (AOF or RDB snapshots) on the Premium tier saves data to disk so sessions survive failover events.
Question 6: A developer deploys a new version of an API to Azure API Management using a revision. They want 10% of live traffic to be routed to the new revision while the old one handles 90%. What APIM feature enables this?
- Create a named version and use a rate-limiting policy
- Use a set-backend-service policy with a random condition (Correct answer)
- Publish the new revision as a separate API version with traffic splitting
- Use Azure Front Door weighted routing in front of APIM
Correct answer: Use a set-backend-service policy with a random condition
A set-backend-service policy with a random number condition can route a percentage of requests to a different backend, implementing canary-style traffic splitting within APIM.
Question 7: An Azure Function connects to an Azure SQL Database. Under load, the function exhausts the SQL connection pool. What is the recommended fix?
- Use a static SqlConnection instance or dependency injection to reuse a single connection across invocations (Correct answer)
- Increase maxPoolSize in the connection string to 1000
- Switch to Azure Cosmos DB to avoid relational connection pooling
- Wrap each query in a new using block to release connections faster
Correct answer: Use a static SqlConnection instance or dependency injection to reuse a single connection across invocations
Azure Functions can create many instances; a static or DI-managed SqlConnection reuses the connection pool across invocations rather than opening a new connection per invocation.
A company's Azure Function uses a Storage Queue trigger.
During a traffic spike, 50,000 messages arrive and the function scales out.
Developers notice duplicate message processing.
What is causing this and how should it be addressed?