public async Task BackupAndRestoreSampleSync()
        {
            var blobStorageUrl    = TestEnvironment.StorageUri;
            var blobContainerName = BlobContainerName;
            var sasToken          = "?" + SasToken;

            #region Snippet:HelloFullBackupSync
            // Create a Uri with the storage container
            UriBuilder builder = new UriBuilder(blobStorageUrl)
            {
                Path = blobContainerName,
            };

            // Start the backup.
            BackupOperation backupOperation = Client.StartBackup(builder.Uri, sasToken);

            // Wait for completion of the BackupOperation.
            while (!backupOperation.HasCompleted)
            {
                backupOperation.UpdateStatus();
                /*@@*/ await DelayAsync(TimeSpan.FromSeconds(3));

                //@@Thread.Sleep(3000);
            }

            // Get the Uri for the location of you backup blob.
            Uri backupFolderUri = backupOperation.Value;
            #endregion

            Assert.That(backupFolderUri, Is.Not.Null);
            Assert.That(backupOperation.HasValue, Is.True);

            await WaitForOperationAsync();

            #region Snippet:HelloFullRestoreSync
            // Start the restore using the backupBlobUri returned from a previous BackupOperation.
            RestoreOperation restoreOperation = Client.StartRestore(backupFolderUri, sasToken);

            // Wait for completion of the RestoreOperation.
            while (!restoreOperation.HasCompleted)
            {
                restoreOperation.UpdateStatus();
                /*@@*/ await DelayAsync(TimeSpan.FromSeconds(3));

                //@@Thread.Sleep(3000);
            }
            Uri restoreResult = backupOperation.Value;
            #endregion

            Assert.That(restoreResult, Is.Not.Null);
            Assert.That(restoreOperation.HasValue, Is.True);

            await WaitForOperationAsync();
        }
Esempio n. 2
0
        public void BackupAndRestoreSampleSync()
        {
            var blobStorageUrl    = TestEnvironment.StorageUri;
            var blobContainerName = BlobContainerName;
            var sasToken          = "?" + SasToken;

            #region Snippet:HelloFullBackupSync
            // Create a Uri with the storage container
            UriBuilder builder = new UriBuilder(blobStorageUrl)
            {
                Path = blobContainerName,
            };

            // Start the backup.
            BackupOperation backupOperation = Client.StartBackup(builder.Uri, sasToken);

            // Wait for completion of the BackupOperation.
            while (!backupOperation.HasCompleted)
            {
                backupOperation.UpdateStatus();
                Thread.Sleep(3000);
            }

            // Get the Uri for the location of you backup blob.
            Uri backupBlobUri = backupOperation.Value;
            #endregion

            Assert.That(backupBlobUri, Is.Not.Null);
            Assert.That(backupOperation.HasValue, Is.True);

            #region Snippet:HelloFullRestoreSync
            // Get the folder name from the backupBlobUri returned from a previous BackupOperation
            string[] uriSegments = backupBlobUri.Segments;
            string   folderName  = uriSegments[uriSegments.Length - 1];

            // Start the restore.
            RestoreOperation restoreOperation = Client.StartRestore(builder.Uri, sasToken, folderName);

            // Wait for completion of the RestoreOperation.
            while (!restoreOperation.HasCompleted)
            {
                restoreOperation.UpdateStatus();
                Thread.Sleep(3000);
            }
            Uri restoreResult = backupOperation.Value;
            #endregion

            Assert.That(restoreResult, Is.Not.Null);
            Assert.That(restoreOperation.HasValue, Is.True);
        }