An enterprise data ingestion workflow in C# uses the Azure.Storage.Blobs SDK (v12) to process telemetry payloads. To prevent concurrent write conflicts on a shared blob named `active_logs.json`, the workflow must acquire an exclusive 30-second write lock (lease), perform the upload, and subsequently update the blob's metadata. Consider the following code skeleton:
csharp
using Azure.Storage.Blobs;
using Azure.Storage.Blobs.Models;
using Azure.Storage.Blobs.Specialized;
using System;
using System.IO;
using System.Collections.Generic;
using System.Threading.Tasks;
public class LogProcessor
{ public static async Task UploadLogWithLeaseAsync(BlobClient blobClient, Stream logStream)
{
BlobLeaseClient leaseClient = blobClient.GetBlobLeaseClient();
BlobLease lease = await leaseClient.AcquireAsync(TimeSpan.FromSeconds(30));
// Configure upload options
BlobUploadOptions uploadOptions = new BlobUploadOptions();
// Execute upload
await blobClient.UploadAsync(logStream, uploadOptions);
// Update metadata
var metadata = new Dictionary<string, string>
{ { "Status", "Processed" }
};
await blobClient.SetMetadataAsync(metadata);
}
}
If you execute this code, the write operations will fail because the active lease ID is not supplied to the operations. Which of the following changes must you implement to ensure both the upload and metadata update operations succeed under the active lease? (Select TWO options.)
- Assign a new `BlobRequestConditions` object to `uploadOptions.Conditions` with its `LeaseId` property set to `lease.LeaseId`.Answer
- Pass a new `BlobRequestConditions` object with its `LeaseId` property set to `lease.LeaseId` as the second parameter (`conditions`) in the `SetMetadataAsync` call.Answer
- CAdd a key-value pair of `x-ms-lease-id` and `lease.LeaseId` directly to the `metadata` dictionary before calling `SetMetadataAsync`.
- DSet `uploadOptions.HttpHeaders` to a new `BlobHttpHeaders` instance and add a custom header named `x-ms-meta-lease-id` containing `lease.LeaseId`.