Soru

Zorluk: OrtaManage Properties, Metadata, and Access Tiers for Azure Blob Storage

You are developing a batch processing system in C# that optimizes storage costs. The system retrieves blobs from a Hot container, adds a metadata key-value pair of "ArchivedBy: BatchProcessor", and then transitions them to the Archive access tier using the Azure.Storage.Blobs SDK.

The current implementation contains the following code:

csharp
// blobClient is a valid instance of BlobClient
await blobClient.SetAccessTierAsync(AccessTier.Archive);
var metadata = new Dictionary<string, string> { { "ArchivedBy", "BatchProcessor" } };
await blobClient.SetMetadataAsync(metadata);

During testing, the system throws a RequestFailedException at the last line.

Which of the following changes must you make to resolve this error?

  1. Update the metadata by calling SetMetadataAsync before changing the access tier to Archive, as writing metadata is not supported on blobs that are already in the Archive tier.Cevap
  2. B
    Acquire a write lease on the blob by calling GetBlobLeaseClient before calling SetMetadataAsync, as archived blobs require an active lease to allow metadata modifications.
  3. C
    Modify the metadata key to use only lowercase letters because Azure Blob Storage metadata keys are case-sensitive and uppercase keys are rejected when a blob is archived.
  4. D
    Regenerate the Shared Access Signature (SAS) token used to instantiate the BlobClient to include the Delete permission, which is required to write metadata to an archived blob.

Cevap

Update the metadata by calling SetMetadataAsync before changing the access tier to Archive, as writing metadata is not supported on blobs that are already in the Archive tier.
The correct answer is correct because once a blob is transitioned to the Archive access tier, it enters an offline state where only limited operations are supported (such as reading properties/metadata or changing/rehydrating the tier). Direct write operations on properties and metadata, such as calling SetMetadataAsync, are explicitly blocked by Azure Blob Storage. Therefore, metadata must be written while the blob is still in an active tier (Hot or Cool) before the tier transition takes place.

Adım Adım Çözüm

1
Set the metadata of the blob while it is still in the Hot tier using the SDK's SetMetadataAsync method.
The blob's metadata is successfully written and updated on the server.
Blobs in active tiers (Hot/Cool) permit full read/write access to both properties and metadata.
2
Transition the blob to the Archive tier using the SetAccessTierAsync method.
The blob is moved to the Archive tier, retaining the metadata that was set in the previous step.
Once the blob is archived, metadata cannot be modified, but pre-existing metadata remains readable.

Anahtar Kavram

Azure Blob Storage Archive access tier write limitations
Bu soruyu puanla