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


C# CloudStorageAccount.CreateCloudBlobClient方法代码示例

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


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

示例1: SharedAccessSignatureController

        public SharedAccessSignatureController(CloudStorageAccount storageAccount)
        {
            if (storageAccount == null)
                throw new ArgumentNullException("storageAccount", Constants.CloudStorageAccountNullArgumentErrorMessage);

            this.cloudBlobClient = storageAccount.CreateCloudBlobClient();
        }
开发者ID:wadewegner,项目名称:TechEd_NZAU,代码行数:7,代码来源:SharedAccessSignatureController.cs

示例2: CopyBlockBlob

        /// <summary>
        /// Copies a blob from one account and container to another.
        /// </summary>
        /// <param name="copyBlockBlobSettings">A <see cref="CopyBlockBlobSettings"/>.</param>
        public static void CopyBlockBlob(CopyBlockBlobSettings copyBlockBlobSettings)
        {
            Contract.Requires(copyBlockBlobSettings != null, "The copy block blob settings cannot be null.");

            var sourceStorageAccount = new CloudStorageAccount(new StorageCredentialsAccountAndKey(copyBlockBlobSettings.BlobStorageSource, copyBlockBlobSettings.BlobStorageSourceKey), copyBlockBlobSettings.UseHttps);
            var sourceClient = sourceStorageAccount.CreateCloudBlobClient();
            var destinationStorageAccount = new CloudStorageAccount(new StorageCredentialsAccountAndKey(copyBlockBlobSettings.BlobStorageDestination, copyBlockBlobSettings.BlobStorageDestinationKey), copyBlockBlobSettings.UseHttps);
            var destinationClient = destinationStorageAccount.CreateCloudBlobClient();
            var destinationContainer = destinationClient.GetContainerReference(copyBlockBlobSettings.DestinationContainerName);

            try
            {
                destinationContainer.CreateIfNotExist();
            }
            catch
            {
                // do nothing, create if not exists blows up if it already exists... nice.
            }

            var sourceBlob = sourceClient.GetBlockBlobReference(copyBlockBlobSettings.BlobSourcePath);
            sourceBlob.FetchAttributes();

            CloudBlob destinationBlob = destinationClient.GetBlockBlobReference(copyBlockBlobSettings.BlobDestinationPath);

            destinationBlob.StartCopyFromBlob(sourceBlob.Uri);

            MonitorCopy(destinationBlob.Container);
        }
开发者ID:amido,项目名称:Amido.Testing,代码行数:32,代码来源:BlobStorage.cs

示例3: AzureStorageProvider

        public AzureStorageProvider(CloudStorageAccount storageAccount)
        {
            cloudStorageAccount = storageAccount;

            // Create the blob client
            blobStorage = cloudStorageAccount.CreateCloudBlobClient();
        }
开发者ID:CloudMorph,项目名称:CloudMorph,代码行数:7,代码来源:AzureStorageProvider.cs

示例4: WorkerRoleLoader

        public WorkerRoleLoader()
        {
            this.LastModified = DateTime.MinValue;

            this.storageAccount = CloudStorageAccount.FromConfigurationSetting(DataConfigurationKey);
            this.blobStorage = storageAccount.CreateCloudBlobClient();
        }
开发者ID:southworks,项目名称:workerroleaccelerator,代码行数:7,代码来源:WorkerRoleLoader.cs

示例5: OnStart

        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 100;

            //Initialize Indexer
            storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("CrawlerStorage"));

            //Initialize URL Queue
            urlQueueClient = storageAccount.CreateCloudQueueClient();
            urlQueue = urlQueueClient.GetQueueReference("urlqueue");
            if (urlQueue.CreateIfNotExist())
            {
                //Add first URL to the queue
                CloudQueueMessage firstURL = new CloudQueueMessage(startURL);
                urlQueue.AddMessage(firstURL);
            }

            //Initialize Index Queue
            indexQueueClient = storageAccount.CreateCloudQueueClient();
            indexQueue = indexQueueClient.GetQueueReference("indexqueue");
            indexQueue.CreateIfNotExist();

            //Initialize Database Blob
            databaseClient = storageAccount.CreateCloudBlobClient();
            databaseContainer = databaseClient.GetContainerReference("wordfrequencies");
            databaseContainer.CreateIfNotExist();
            var permission = databaseContainer.GetPermissions();
            permission.PublicAccess = BlobContainerPublicAccessType.Container;
            databaseContainer.SetPermissions(permission);

            return base.OnStart();
        }
开发者ID:nicolas3470,项目名称:Distributed-Web-Crawler,代码行数:33,代码来源:WorkerRole.cs

示例6: OnInitialize

        private void OnInitialize()
        {
            var selfInstance        = InstanceEnumerator.GetSelf();

            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.RoleName, selfInstance.RoleInstanceIndex).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.StorageSizeInMb, 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("Executing drive benchmark for: {0}",mountedDirectoryPath);
            ExecuteBenchmarks(mountedDirectory,storageSize);
            log.Info("Storage initialization succeeded");
        }
开发者ID:skovborg,项目名称:RavenDb.Azure,代码行数:60,代码来源:CloudStorageProvider.cs

示例7: NeoServer

 public NeoServer(NeoServerConfiguration configuration, CloudStorageAccount storageAccount)
     : this(configuration,
         new RoleEnvironmentWrapper(),
         new CloudBlobClientWrapper(storageAccount.CreateCloudBlobClient()),
         new FileSystem(),
         new ZipHandler())
 {}
开发者ID:tathamoddie,项目名称:Neo4j.Server.AzureWorkerHost,代码行数:7,代码来源:NeoServer.cs

示例8: Storage

        public Storage(CloudStorageAccount account)
        {
            this.account = account;

            fileStorage = account.CreateCloudBlobClient();

            /* Initialize file container */
            container = fileStorage.GetContainerReference(filesContainer);
            container.CreateIfNotExist();

            var permissions = container.GetPermissions();
            /* Full permissions. From MSDN, Container-level public access. Anonymous clients can
             * read blob content and metadata and container metadata, and can list the blobs within the container.
             *
             * Other alternatives are Blob (can read content but not metadata) and Off (no
             * anonymous access).
             */
            // permissions.PublicAccess = BlobContainerPublicAccessType.Container;
            permissions.PublicAccess = BlobContainerPublicAccessType.Off;

            permissions.SharedAccessPolicies.Remove("basic");
            permissions.SharedAccessPolicies.Add("basic", new SharedAccessPolicy()
            {
            });

            container.SetPermissions(permissions);

            /* Initialize table (for file metadata) */
            CloudTableClient.CreateTablesFromModel(
                typeof(FileDataContext),
                account.TableEndpoint.AbsoluteUri,
                account.Credentials);
        }
开发者ID:davidajulio,项目名称:claims,代码行数:33,代码来源:Storage.cs

示例9: OnStart

        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 12;
            #if DEBUG
            account = CloudStorageAccount.DevelopmentStorageAccount;
            #else
            account = new CloudStorageAccount(accountAndKey, true);
            #endif

            tableContext = new TableServiceContext(account.TableEndpoint.ToString(), account.Credentials);

            //client = new CloudQueueClient(account.BlobEndpoint.ToString(), account.Credentials);
            qclient = account.CreateCloudQueueClient();
            q = qclient.GetQueueReference("icd9mapplotrequests");
            rows = new List<ICD9MapPlotResultEntry>();
            bclient = account.CreateCloudBlobClient();
            container = bclient.GetContainerReference("results");
            container.CreateIfNotExist();
            client = account.CreateCloudTableClient();
            client.CreateTableIfNotExist("ICD9MapPlotResult");
            client.CreateTableIfNotExist("DoctorDetails");
            client.CreateTableIfNotExist("PatientDetails");
            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

            return base.OnStart();
        }
开发者ID:cloudscrubs,项目名称:azureprototype,代码行数:28,代码来源:WorkerRole.cs

示例10: BlobHelper

        // Constructor - get settings from a hosted service configuration or .NET configuration file.
        public BlobHelper(string configurationSettingName, bool hostedService)
        {
            if (hostedService)
            {
                CloudStorageAccount.SetConfigurationSettingPublisher(
                    (configName, configSettingPublisher) =>
                    {
                        var connectionString = RoleEnvironment.GetConfigurationSettingValue(configName);
                        configSettingPublisher(connectionString);
                    }
                );
            }
            else
            {
                CloudStorageAccount.SetConfigurationSettingPublisher(
                    (configName, configSettingPublisher) =>
                    {
                        var connectionString = ConfigurationManager.ConnectionStrings[configName].ConnectionString;
                        configSettingPublisher(connectionString);
                    }
                );
            }

            Account = CloudStorageAccount.FromConfigurationSetting(configurationSettingName);

            BlobClient = Account.CreateCloudBlobClient();
            BlobClient.RetryPolicy = RetryPolicies.Retry(4, TimeSpan.Zero);
        }
开发者ID:nanovazquez,项目名称:azure-query-sample,代码行数:29,代码来源:BlobHelper.cs

示例11: BlobHelper

    // Constructor - pass in a storage connection string.
    public BlobHelper(string connectionString)
    {
        Account = CloudStorageAccount.Parse(connectionString);

            BlobClient = Account.CreateCloudBlobClient();
            BlobClient.RetryPolicy = RetryPolicies.Retry(4, TimeSpan.Zero);
    }
开发者ID:colebank,项目名称:BloodHound,代码行数:8,代码来源:BlobHelper.cs

示例12: BlobOptimisticDataStore

        public BlobOptimisticDataStore(CloudStorageAccount account, string containerName)
        {
            var blobClient = account.CreateCloudBlobClient();
            blobContainer = blobClient.GetContainerReference(containerName.ToLower());
            blobContainer.CreateIfNotExist();

            blobReferences = new Dictionary<string, CloudBlob>();
        }
开发者ID:astaykov,项目名称:SnowMaker,代码行数:8,代码来源:BlobOptimisticDataStore.cs

示例13: AzureStorageClient

        public AzureStorageClient(CloudStorageAccount account)
        {
            client = account.CreateCloudBlobClient();
            client.DefaultDelimiter = "/";

            container = client.GetContainerReference("documents");
            container.CreateIfNotExist();
        }
开发者ID:Amichai,项目名称:Prax,代码行数:8,代码来源:AzureStorageClient.cs

示例14: AzureBlobStore

        internal AzureBlobStore(string accountName, string targetContainer, string accountKey)
        {
            _storageAccount = new CloudStorageAccount(new StorageCredentialsAccountAndKey(accountName, accountKey), true);
            _blobStorage = _storageAccount.CreateCloudBlobClient();
            _targetContainer = targetContainer;

            CreateContainer();
        }
开发者ID:coapp-deprecated,项目名称:AzureSyncbox,代码行数:8,代码来源:AzureBlobStore.cs

示例15: ConnectToBlobStorage

 /// <summary>
 /// Connects to the storage account and creates the default container 
 /// </summary>
 private void ConnectToBlobStorage()
 {
     storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString"));
     blobClient = storageAccount.CreateCloudBlobClient();
     blobContainer = blobClient.GetContainerReference("testcontainer");
     blobContainer.CreateIfNotExist();
     blobContainer.SetPermissions(new BlobContainerPermissions() { PublicAccess = BlobContainerPublicAccessType.Blob });
 }
开发者ID:twopieman,项目名称:PictureService,代码行数:11,代码来源:PictureService.svc.cs


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