public static List<CloudStorageContainer> ImportContainers(string accountName, string accountKey)
        {
            Microsoft.WindowsAzure.Storage.CloudStorageAccount storageAccount = //new Microsoft.WindowsAzure.Storage.CloudStorageAccount()
                Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse(
                    string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1};BlobEndpoint=https://{0}.blob.core.windows.net/", accountName, accountKey)
                   );
            Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
            var containers = blobClient.ListContainers();

            //Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer container = blobClient.GetContainerReference(System.Configuration.ConfigurationManager.AppSettings["AzureDefaultStorage"]);
            // Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer container = blobClient.GetContainerReference(System.Configuration.ConfigurationManager.AppSettings["AzureUserProfilesStorage"]);

            List<CloudStorageContainer> list = new List<CloudStorageContainer>();

            foreach (var azureContainer in containers.OrderBy(c => c.Name)) {
                CloudStorageContainer container = new CloudStorageContainer {
                    //CloudStorageContainerId = azureContainer.Name,
                    //CloudStorageContainerId = Guid.NewGuid().ToString("D").ToLower(),
                    ProviderKey = azureContainer.Name,
                    ContainerName = azureContainer.Name,
                    Alias = azureContainer.Name
                };
                list.Add(container);
            }

            return list;
        }
        public async Task<ActionResult> Create(CloudStorageContainerCreateViewModel model, string returnUrl) {

            //ApplicationDbContext context = new ApplicationDbContext();
            //var providers = context.CloudStorageProviders.ToList();

            //var model = new CloudStorageAccountCreateViewModel {
            //    CloudStorageProviders = providers,
            //    //CloudStorageProviderId = null,
            //    //AccountName = null,
            //    //AccountKey
            //};
            CloudStorageContainer container = new CloudStorageContainer {
                // CloudStorageAccountId = model.AccountName,
                // CloudStorageProviderId = model.CloudStorageProviderId,
                //CloudStorageContainerId = model.CloudStorageContainerId,
                //CloudStorageAccountId = model.CloudStorageAccountId,
                ProviderKey = model.ProviderKey,
                ContainerName = model.ContainerName,
                Alias = string.IsNullOrEmpty(model.Alias) ? model.Alias : model.ContainerName,
                Description = model.Description // ,
            };

            var user = this.CurrentSecurityUser;
            var accounts = user.CloudStorageAccounts.ToList(); //  .Select(m => m.CloudStorageAccountId == model.CloudStorageAccountId).FirstOrDefault();
            var account = accounts.Where(m => m.PublicKey == model.CloudStorageAccountPublicKey).FirstOrDefault();
            // user.CloudStorageAccounts.Add(container);
            account.CloudStorageContainers.Add(container);
            await UserManager.UpdateAsync(user);


            return RedirectToLocal(returnUrl);

            //return View(model);
        }