Microsoft Azure Developer Associate AZ-204 Practice Question
You are developing a .NET 6 worker service that uploads log files to an Azure Blob Storage container by using the Azure.Storage.Blobs SDK (v12). Every uploaded blob must meet these requirements:
The Content-Type header must be set to "text/plain" so that browsers render the file correctly when it is downloaded.
A custom metadata key named "department" must store the originating department code so that you can later filter blobs by that value. You also want to minimize the number of write transactions that are billed. Which code approach should you use to meet all the requirements?
Call BlobClient.UploadAsync(stream, new BlobUploadOptions { HttpHeaders = new BlobHttpHeaders , Metadata = new Dictionary<string,string> { ["department"] = deptCode } });
Upload the blob with overwrite set to true, then call BlobClient.SetTagsAsync(new Dictionary<string,string> { ["department"] = deptCode, ["Content-Type"] = "text/plain" });
Upload the blob, then call BlobClient.SetHttpHeadersAsync(new BlobHttpHeaders ) followed by BlobClient.SetMetadataAsync(new Dictionary<string,string> { ["department"] = deptCode });
Open a writable stream by using BlobClient.OpenWrite(overwrite:true, new BlobOpenWriteOptions { HttpHeaders = new BlobHttpHeaders }) and write the content; metadata is added automatically.
The BlobClient.UploadAsync overload that accepts a BlobUploadOptions object lets you specify both BlobHttpHeaders and Metadata in the same service call. The SDK sends a single Put Blob (or Put Block List) request that writes the content, sets the Content-Type header, and stores the metadata simultaneously. If you instead call SetHttpHeadersAsync and SetMetadataAsync after the upload, each of those additional requests counts as a separate write operation, increasing transaction costs. Using tags or BlobOpenWriteOptions does not satisfy the requirement because tags are stored separately from metadata and BlobOpenWriteOptions cannot set metadata or headers in one request.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is the purpose of BlobHttpHeaders in the Azure.Storage.Blobs SDK?
Open an interactive chat with Bash
Why does calling SetHttpHeadersAsync and SetMetadataAsync increase transaction costs?
Open an interactive chat with Bash
What is the difference between metadata and tags in Azure Blob Storage?
Open an interactive chat with Bash
Microsoft Azure Developer Associate AZ-204
Develop for Azure storage
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99
$19.99/mo
Billed monthly, Cancel any time.
3 Month Pass
$44.99
$14.99/mo
One time purchase of $44.99, Does not auto-renew.
MOST POPULAR
Annual Pass
$119.99
$9.99/mo
One time purchase of $119.99, Does not auto-renew.
BEST DEAL
Lifetime Pass
$189.99
One time purchase, Good for life.
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .