Question

Difficulty: Very hardMove and Copy Blobs between Azure Storage Containers and Accounts

Your development team is implementing a data migration service using the Azure.Storage.Blobs SDK (version 12.x) to migrate large media files from a source container in storage account 'mediaflowsource' to a destination container in storage account 'mediaflowdest' across different Azure regions. The destination blobs are locked with active leases to prevent accidental deletion during the process, and you must overwrite them with the new versions while preserving all user-defined metadata. The source blobs are private, and access must be granted using a Shared Access Signature (SAS) token.

Which of the following actions are required to complete this copy operation successfully? (Select TWO)

  1. Generate a Shared Access Signature (SAS) token for the source blob containing the Read permission, and append this token to the source URI passed to the copy operation.Answer
  2. Instantiate a BlobLeaseClient for the destination blob, and provide the active lease ID in the BlobCopyFromUriOptions.DestinationConditions.LeaseId property.Answer
  3. C
    Generate a SAS token for the source blob with Read and Write permissions, and assign it to the BlobCopyFromUriOptions.SourceConditions.LeaseId property.
  4. D
    Add custom metadata to the BlobCopyFromUriOptions.Metadata dictionary, prefixing each key with 'x-ms-meta-' to prevent metadata loss.

Answer

Generating a Shared Access Signature (SAS) token with Read permission and appending it to the source URI, along with providing the destination blob's active lease ID in the BlobCopyFromUriOptions.DestinationConditions.LeaseId property, are required to successfully complete the copy operation.
To copy a private source blob to a leased destination blob, the Azure Storage copy engine needs Read access to the source blob (provided via a SAS token with Read permission appended to the source URI), and the write request to the destination blob must include the active lease ID in the destination conditions (BlobCopyFromUriOptions.DestinationConditions.LeaseId) to authorize the overwrite.

Step-by-Step Solution

1
Generate a SAS token for the source blob with Read permissions and append it to the source blob's URI.
A secure source URI is created, enabling the Azure Storage service to access and copy the source blob.
Since the source blob is private and located in a different storage account, the Azure Storage copy engine requires read access to the source content.
2
Obtain the lease ID of the active lease on the destination blob using BlobLeaseClient.
The active lease ID is retrieved for authorization.
Modifying or overwriting a leased blob requires the lease ID to bypass the write lease protection.
3
Call StartCopyFromUriAsync on the destination BlobClient, passing the source URI and configuring the LeaseId in BlobCopyFromUriOptions.DestinationConditions.
The asynchronous copy operation is initiated successfully without throwing a 412 Precondition Failed error.
Providing the lease ID in the destination conditions permits the copy engine to overwrite the leased destination blob.

Key Concept

Asynchronous blob copying between storage accounts with source SAS authorization and destination lease handling using the .NET Azure.Storage.Blobs SDK.
Rate this question