本文整理汇总了C#中Microsoft.WindowsAzure.StorageClient.CloudBlobClient.ListContainers方法的典型用法代码示例。如果您正苦于以下问题:C# CloudBlobClient.ListContainers方法的具体用法?C# CloudBlobClient.ListContainers怎么用?C# CloudBlobClient.ListContainers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.WindowsAzure.StorageClient.CloudBlobClient
的用法示例。
在下文中一共展示了CloudBlobClient.ListContainers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnInitialize
private void OnInitialize()
{
var selfInstance = InstanceEnumerator.EnumerateInstances().First(i => i.IsSelf);
cloudStorageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(ConfigurationSettingsKeys.StorageConnectionString));
log.Info("Storage account selected: {0}",cloudStorageAccount.BlobEndpoint);
cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient();
log.Info("Storage client created");
var containerName = ConfigurationProvider.GetSetting(ConfigurationSettingsKeys.StorageContainerName,"ravendb");
// In order to force a connection we just enumerate all available containers:
var availableContainers = cloudBlobClient.ListContainers().ToArray();
foreach (var container in availableContainers)
{
log.Info("Available container: {0}",container.Name);
}
if (!availableContainers.Any(c => c.Name.Equals(containerName)))
{
log.Info("Container {0} does not exist, creating",containerName);
// Container does not exist:
cloudBlobClient.GetContainerReference(containerName).Create();
}
cloudBlobContainer = cloudBlobClient.GetContainerReference(containerName);
log.Info("Container {0} selected",cloudBlobContainer.Name);
localCache = RoleEnvironment.GetLocalResource(ConfigurationSettingsKeys.StorageCacheResource);
log.Info("Cache resource retrieved: {0}, path: {1}",localCache.Name,localCache.RootPath);
CloudDrive.InitializeCache(localCache.RootPath, localCache.MaximumSizeInMegabytes);
log.Info("Cache initialized: {0} mb",localCache.MaximumSizeInMegabytes);
var driveName = string.Format("{0}{1}.vhd", selfInstance.InstanceType, selfInstance.InstanceIndex).ToLowerInvariant();
log.Info("Virtual drive name: {0}",driveName);
var pageBlob = cloudBlobContainer.GetPageBlobReference(driveName);
log.Info("Virtual drive blob: {0}",pageBlob.Uri);
cloudDrive = cloudStorageAccount.CreateCloudDrive(pageBlob.Uri.ToString());
log.Info("Virtual drive created: {0}",cloudDrive.Uri);
var storageSize = ConfigurationProvider.GetSetting(ConfigurationSettingsKeys.StorageSize, 50000);
log.Info("Storage size: {0} mb",storageSize);
cloudDrive.CreateIfNotExist(storageSize);
log.Info("Virtual drive initialized: {0}",cloudDrive.Uri);
var mountedDirectoryPath = cloudDrive.Mount(storageSize, DriveMountOptions.None);
log.Info("Virtual drive mounted at: {0}",mountedDirectoryPath);
mountedDirectory = new DirectoryInfo(mountedDirectoryPath);
log.Info("Ensuring drive is available: {0}",mountedDirectoryPath);
UpdateTestFile();
log.Info("Storage initialization succeeded");
}