Soru

Zorluk: OrtaMove and Copy Blobs between Azure Storage Containers and Accounts

You are developing an application using the .NET Azure.Storage.Blobs SDK (version 12) to copy a blob from a source container to a destination container. The destination blob already exists and is locked with an active, exclusive write lease. You possess the lease ID for the destination blob. Which of the following approaches should you use to successfully perform the copy operation?

  1. Instantiate a BlobCopyFromUriOptions object, assign the lease ID to the LeaseId property of its DestinationConditions, and pass the options to StartCopyFromUriAsync.Cevap
  2. B
    Instantiate a BlobCopyFromUriOptions object, assign the lease ID to the LeaseId property of its SourceConditions, and pass the options to StartCopyFromUriAsync.
  3. C
    Acquire an identical lease on the source blob using the destination blob's lease ID before calling StartCopyFromUriAsync without copy options.
  4. D
    Generate a Shared Access Signature (SAS) token for the destination container containing the lease ID, and append this token to the destination blob's URI.

Cevap

Instantiate a BlobCopyFromUriOptions object, assign the lease ID to the LeaseId property of its DestinationConditions, and pass the options to StartCopyFromUriAsync.
The option stating to instantiate a BlobCopyFromUriOptions object and assign the lease ID to its DestinationConditions is correct because it ensures that the active write lease on the destination blob is authorized during the write operation. The Azure Storage service validates this lease ID against the active lease on the destination blob to allow the copy operation to overwrite it.

Adım Adım Çözüm

1
Initialize a BlobRequestConditions object and assign the active lease ID of the destination blob to its LeaseId property.
A BlobRequestConditions instance configured with the correct lease authorization.
This condition ensures the write operation is permitted on the leased destination blob.
2
Instantiate a BlobCopyFromUriOptions object and assign the BlobRequestConditions to its DestinationConditions property.
A BlobCopyFromUriOptions instance specifying that the lease condition applies to the destination target.
The destination container and blob are the ones undergoing modification, so the lease ID must target the destination.
3
Invoke StartCopyFromUriAsync on the destination BlobClient, passing the source URI and the BlobCopyFromUriOptions object.
The asynchronous copy operation begins successfully without throwing a 412412 (Precondition Failed) error.
The Azure Storage service receives the lease ID in the request headers and allows the write to proceed on the leased blob.

Anahtar Kavram

Using BlobCopyFromUriOptions and DestinationConditions to overwrite a leased destination blob during a copy operation.
Bu soruyu puanla