You are developing a C# service that updates the metadata of a blob in Azure Blob Storage using the Azure.Storage.Blobs SDK. The target blob is currently locked with an active lease. You have the lease ID stored in a variable named `activeLeaseId` and the metadata dictionary stored in a variable named `metadata`.
Which of the following code segments should you use to successfully update the blob's metadata?
- await blobClient.SetMetadataAsync(metadata, new BlobRequestConditions { LeaseId = activeLeaseId });Cevap
- Bawait blobClient.SetMetadataAsync(metadata);
- Cawait blobClient.SetMetadataAsync(metadata, activeLeaseId);
- Dawait blobClient.SetMetadataAsync(metadata, new RequestConditions { IfMatch = new ETag(activeLeaseId) });
Cevap
The correct option is the one that calls the SetMetadataAsync method with a BlobRequestConditions object containing the LeaseId property set to the active lease ID.
The correct code block initializes a BlobRequestConditions object and sets its LeaseId property to the activeLeaseId. This object is then passed as the second argument to SetMetadataAsync, which correctly informs Azure Blob Storage of the authorized lease hold for the write operation.
Adım Adım Çözüm
Anahtar Kavram
To modify a leased blob or its metadata, you must provide the active lease ID using the BlobRequestConditions class in the Azure.Storage.Blobs SDK.
Tahmini Süre:1m 30s