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?
- 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
- BAcquire a write lease on the blob by calling GetBlobLeaseClient before calling SetMetadataAsync, as archived blobs require an active lease to allow metadata modifications.
- CModify 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.
- DRegenerate 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
Anahtar Kavram
Azure Blob Storage Archive access tier write limitations