当前位置: 首页>>代码示例>>C#>>正文


C# CloudBlobContainer.GetPageBlobReference方法代码示例

本文整理汇总了C#中Microsoft.WindowsAzure.StorageClient.CloudBlobContainer.GetPageBlobReference方法的典型用法代码示例。如果您正苦于以下问题:C# CloudBlobContainer.GetPageBlobReference方法的具体用法?C# CloudBlobContainer.GetPageBlobReference怎么用?C# CloudBlobContainer.GetPageBlobReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.WindowsAzure.StorageClient.CloudBlobContainer的用法示例。


在下文中一共展示了CloudBlobContainer.GetPageBlobReference方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MountDrive

        public static string MountDrive(string containerName, string vhdName, int driveSize, int driveLocalReadCacheSize)
        {
            var client = GetCloudClientInstance();

            // Create the container for the drive if it does not already exist.
            var container = new CloudBlobContainer(containerName, client);
            if (container.CreateIfNotExist())
            {
                container.SetPermissions(new BlobContainerPermissions {PublicAccess = BlobContainerPublicAccessType.Off});
            }

            var cloudDrive = new CloudDrive(container.GetPageBlobReference(vhdName).Uri, client.Credentials);
            try
            {
                cloudDrive.Create(driveSize);
            }
            catch (CloudDriveException ex)
            {
                Logger.Info(string.Format("Cloud drive already exists. Uri: {0}", cloudDrive.Uri), ex);
            }

            string pathToDrive = cloudDrive.Mount(driveLocalReadCacheSize, DriveMountOptions.Force);
            return pathToDrive;
        }
开发者ID:jalchr,项目名称:Azure-IIS-Hosted-RavenDb,代码行数:24,代码来源:AzureCloudDrive.cs

示例2: CreateDriveEx

        public void CreateDriveEx()
        {
            try
            {
                CloudBlobClient client = _account.CreateCloudBlobClient();

                // Create the container for the drive if it does not already exist.
                CloudBlobContainer container = new CloudBlobContainer("mydrives", client);
                container.CreateIfNotExist();

                // Get a reference to the page blob that will back the drive.
                CloudPageBlob pageBlob = container.GetPageBlobReference(_vhdName);
                _cloudDrive = new CloudDrive(pageBlob.Uri, _account.Credentials);

                //_cloudDrive = _account.CreateCloudDrive(_vhdName);
                _logger.Log("using account " + _account.BlobEndpoint + " to create " + _vhdName);
                var rv = _cloudDrive.CreateIfNotExist(DISK_SIZE);
                _logger.Log("done create drive");
            }
            catch (Exception ex)
            {
                _logger.Log("error on CreateDrive", ex);
            }
        }
开发者ID:yjddd412213,项目名称:CloudDriveManager,代码行数:24,代码来源:CloudDriveManager.cs

示例3: 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");
        }
开发者ID:jalchr,项目名称:RavenDb.Azure,代码行数:61,代码来源:CloudStorageProvider.cs


注:本文中的Microsoft.WindowsAzure.StorageClient.CloudBlobContainer.GetPageBlobReference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。