ReplicateBlobAsync() public method

Replicates a blob from the current storage account to a target storage account
public ReplicateBlobAsync ( string targetConnectionString, string sourceContainerName, string targetContainerName, string blobName, TextWriter log ) : Task
targetConnectionString string Connection string of the target storage account
sourceContainerName string The source container
targetContainerName string The target container
blobName string The blob to replicate
log System.IO.TextWriter TextWriter used for logging
return Task
Example #1
0
        internal static async Task ReplicateBlobAsync(PhotoModel model, TextWriter log)
        {
            //The source connection string needs to be in AppSettings using the
            //storage account name.
            var sourceConnectionString = ConfigurationManager.AppSettings[model.StorageAccountName];

            //The target connection string is the local region's storage account
            var targetConnectionString = SettingsHelper.LocalStorageConnectionString;

            //Copy from the upload container to the photos container,
            //    potentially across storage accounts
            await log.WriteLineAsync("sourceConnectionString: " + sourceConnectionString);
            await log.WriteLineAsync("targetConnectionString: " + targetConnectionString);

            var storageRepo = new StorageRepository(sourceConnectionString);
            var container = await storageRepo.ReplicateBlobAsync(
                targetConnectionString,
                StorageConfig.UserUploadBlobContainerName,
                StorageConfig.PhotosBlobContainerName,
                model.ServerFileName, log);

            //Monitor the copy operation and wait for it to finish
            //before proceeding
            await storageRepo.MonitorCopy(container, model.ServerFileName, log);
        }