You are developing a C# background service that processes large video files stored in Azure Blob Storage using the Azure.Storage.Blobs SDK (v12). To prevent multiple instances of the service from processing the same video simultaneously, each instance first acquires an exclusive lease on the target blob. Once processing is complete, the service must perform the following tasks in a thread-safe manner that maintains the concurrency lock until all changes are committed:
1. Write a custom metadata tag to the blob with the key "Status" and the value "Processed".
2. Release the lease immediately afterward to allow other services to access the blob.
The helper method signature is defined as follows:
csharp
public async Task CompleteProcessingAsync(BlobClient blobClient, BlobLeaseClient leaseClient, string leaseId)
{
// Implementation
}
Which of the following code blocks should you use to implement this method?
- Acsharp
var metadata = new Dictionary<string, string> { { "Status", "Processed" } };
await leaseClient.ReleaseAsync();
await blobClient.SetMetadataAsync(metadata); - Bcsharp
var metadata = new Dictionary<string, string> { { "x-ms-meta-Status", "Processed" } };
var conditions = new BlobRequestConditions { LeaseId = leaseId };
await blobClient.SetMetadataAsync(metadata, conditions);
await leaseClient.ReleaseAsync(); - csharp
var metadata = new Dictionary<string, string> { { "Status", "Processed" } };
var conditions = new BlobRequestConditions { LeaseId = leaseId };
await blobClient.SetMetadataAsync(metadata, conditions);
await leaseClient.ReleaseAsync();
Cevap - Dcsharp
var metadata = new Dictionary<string, string> { { "Status", "Processed" } };
await blobClient.SetMetadataAsync(metadata);
await leaseClient.ReleaseAsync();