Courseiva
Develop for Azure storagemediumMultiple ChoiceObjective-mapped

AZ-204 Develop for Azure storage Practice Question

You are developing a .NET 8 application that stores customer data in Azure Blob Storage. The application uses the Azure.Storage.Blobs SDK. You need to ensure that the blob containers are created only if they do not already exist. Which method should you call?

⚠ Common exam trap

Many exam-takers confuse `CreateIfNotExistsAsync` with `CreateAsync`, assuming that `CreateAsync` will silently succeed if the container exists, when in fact it throws an exception on conflict, leading to unhandled errors in production code.

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

CreateIfNotExistsAsync

The `CreateIfNotExistsAsync` method is the correct choice because it atomically checks for the existence of the blob container and creates it only if it does not already exist, returning a Boolean indicating whether creation occurred. This aligns with the requirement to avoid errors when the container already exists, without requiring a separate existence check.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ExistsAsync

    Why it's wrong here

    The `ExistsAsync` method in the Azure Blob Storage client library is designed solely to verify the presence of a container within a storage account. It performs a lightweight check, typically a HEAD request to the Azure Storage REST API, returning a boolean value indicating whether the container exists. This method does not initiate any creation process, making it unsuitable for scenarios where the goal is to ensure a container is available for use, as it will not provision the resource if it's missing.

  • DeleteIfExistsAsync

    Why it's wrong here

    The `DeleteIfExistsAsync` method is specifically intended for resource cleanup and management, allowing an application to remove an Azure Blob Storage container if it currently exists. Upon invocation, it checks for the container's presence and, if found, proceeds to delete it. This operation is destructive and ensures the container is absent, which directly contradicts the objective of ensuring a container is present and ready for data storage.

  • CreateIfNotExistsAsync

    Why this is correct

    The `CreateIfNotExistsAsync` method provides an idempotent and robust mechanism for ensuring an Azure Blob Storage container is available. It intelligently first checks if a container with the specified name already exists in the storage account. If the container is not found, it then proceeds to create it. This approach prevents `RequestFailedException` errors that would occur if attempting to create an already existing container, making it ideal for reliably provisioning resources without complex conditional logic.

  • CreateAsync

    Why it's wrong here

    The `CreateAsync` method attempts to unconditionally create a new Azure Blob Storage container with the specified name. If a container with that exact name already exists within the storage account, invoking `CreateAsync` will result in a `RequestFailedException` with an HTTP 409 (Conflict) status code. This behavior necessitates explicit error handling or prior existence checks to avoid runtime failures, making it less suitable for scenarios where the container might already exist and idempotency is desired.

Quick reference

Azure Blob Storage Tier Comparison

TierStorage CostRetrieval CostLatencyUse Case
HotHighestLowestImmediateActive data, frequent reads
CoolLowerHigherImmediateData accessed < once / month
ColdLower stillHigherImmediateData accessed < once / quarter
ArchiveLowestHighest + rehydration delayHoursLong-term compliance retention

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 →

How Courseiva writes practice questions · Editorial policy

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.