Microsoft Certified: Azure Developer Associate (AZ-204)Develop for Azure storageHard

A developer is writing code to manage blobs in Azure Blob Storage. The application needs to list all blobs within a specific container that have a particular prefix and were modified after a certain date. Which method from the Azure Blob Storage client library for .NET should the developer use for the most efficient retrieval?

  1. AGetBlobsAsync() with the `prefix` parameter and iterate through the results.
  2. BGetBlobsAsync() with no parameters and then filter client-side.
  3. CGetBlobsAsync() with the `prefix` parameter and then filter client-side by date.
  4. DGetBlobsAsync() with `prefix` and `conditions` (including ModifiedSince) parameters.
Show answer & explanation

Correct answer: A. GetBlobsAsync() with the `prefix` parameter and iterate through the results.

The Azure Blob Storage client library's `GetBlobsAsync()` method (or `GetBlobs` for older versions) allows specifying a `prefix` parameter. This filters blobs at the service level, significantly reducing the amount of data transferred and processed. While the client library doesn't directly support server-side filtering by 'ModifiedSince' as a direct parameter to `GetBlobsAsync` for listing, filtering by prefix is the most efficient server-side operation available for partial listing. The date filtering would then occur client-side on the already-prefixed results.

Why the other options are wrong

  • B. Retrieving all blobs and filtering client-side is highly inefficient for large containers as it transfers unnecessary data.
  • C. Filtering by prefix server-side is good, but `GetBlobsAsync` does not have a direct `ModifiedSince` parameter for server-side filtering. So, client-side date filtering would still be necessary, but on a much smaller result set.
  • D. The `GetBlobsAsync` method does not directly support a `ModifiedSince` condition as a server-side filter parameter for listing blobs; `conditions` are typically related to a single blob's properties for operations like `DownloadContentAsync`.

Blob Listing with Prefix

When listing blobs in Azure Blob Storage, specifying a `prefix` parameter allows the storage service to filter the results on the server side before sending them to the client. This significantly improves performance and reduces network bandwidth usage, especially for containers with many blobs.

  • Filters blob list results at the service level.
  • Reduces data transferred to the client.
  • Improves performance for large containers.
  • An integral part of efficient blob management.

Memory trick: Prefix Pushes Processing to the Platform.

More Develop for Azure storage questions