コード例 #1
0
        /// <summary>
        /// Exports the list of containers in a given storage account
        /// </summary>
        /// <param name="account">Storage account to get the name and key of the storage account whose blobs are to be exported</param>
        /// <returns>List of storage account containers</returns>
        private List <Container> ExportStorageAccountContainers(Microsoft.WindowsAzure.Management.Storage.Models.StorageAccount account)
        {
            string           methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
            List <Container> containers = new List <Container>();

            try
            {
                string srcStorageAccountKey = GetStorageAccountKeysFromMSAzure(exportParameters.SourceSubscriptionSettings.Credentials, account.Name).PrimaryKey;

                Microsoft.WindowsAzure.Storage.CloudStorageAccount storageAccount =
                    new Microsoft.WindowsAzure.Storage.CloudStorageAccount(
                        new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(account.Name, srcStorageAccountKey), true);
                CloudBlobClient cloudBlobClient = storageAccount.CreateCloudBlobClient();

                foreach (var item in cloudBlobClient.ListContainers())
                {
                    List <Blob> blobs = new List <Blob>();
                    containers.Add(new Container
                    {
                        ContainerName = item.Name,
                        BlobDetails   = ExportBlobs(item.ListBlobs(null, false), blobs)
                    });
                }

                return(containers);
            }
            catch (Exception ex)
            {
                Logger.Error(methodName, ex);
                throw;
            }
        }
        private static bool VerifyStorageAccount(
            StorageAccount storageCreated,
            string storageAccountName,
            string label,
            string description,
            string location,
            string accountType)
        {
            bool verified = true;

            verified &= storageCreated.Name == storageAccountName;
            verified &= storageCreated.Uri.ToString().Contains(storageAccountName);
            verified &= storageCreated.Name == storageAccountName;
            verified &= storageCreated.Properties.Label == label;
            verified &= storageCreated.Properties.Description == description;
            verified &= storageCreated.Properties.Location == location;
            verified &= storageCreated.Properties.AccountType == accountType;

            return verified;
        }
コード例 #3
0
 public static string StorageAccountAsString(StorageAccount sa)
 {
     var sb = new StringBuilder();
     sb.AppendLine("Name: ".PadRight(30) + sa.Name);
     sb.AppendLine("Location: ".PadRight(30) + sa.Properties.Location);
     return sb.ToString();
 }
コード例 #4
0
        private static bool TryGetStorageAccount(IStorageManagementClient storageClient, string storageAccountName, out StorageAccount storageAccount)
        {
            try
            {
                storageAccount = storageClient.StorageAccounts.Get(storageAccountName).StorageAccount;
            }
            catch
            {
                storageAccount = null;
            }

            return storageAccount != null;
        }
コード例 #5
0
 /// <summary>
 ///     Create storage blob.
 ///     Note: storage container name should be in lower case
 /// </summary>
 /// <param name="service"></param>
 /// <param name="blobName"></param>
 /// <param name="containerName"></param>
 /// <returns></returns>
 public CloudBlockBlob CreateBlob(StorageAccount service, string blobName, string containerName = "")
 {
     return service.CreateBlob(blobName, containerName);
 }
コード例 #6
0
 /// <summary>
 ///     Create storage container.
 ///     Note: storage container name should be in lower case
 /// </summary>
 /// <param name="service"></param>
 /// <param name="containerName"></param>
 /// <returns></returns>
 public CloudBlobContainer CreateContainer(StorageAccount service, string containerName = "")
 {
     return service.CreateContainer(containerName);
 }
コード例 #7
0
        internal static void LogObject(this TestEasyLog log, StorageAccount storageService)
        {
            if (storageService == null) return;

            if (!string.IsNullOrEmpty(storageService.Name))
            {
                log.Info(string.Format("StorageService Name:{0}", storageService.Name));
            }

            log.Info(string.Format("StorageService Url:{0}", storageService.Uri));
        }