當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。