本文整理汇总了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();
}
示例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);
}
示例3: AzureStorageProvider
public AzureStorageProvider(CloudStorageAccount storageAccount)
{
cloudStorageAccount = storageAccount;
// Create the blob client
blobStorage = cloudStorageAccount.CreateCloudBlobClient();
}
示例4: WorkerRoleLoader
public WorkerRoleLoader()
{
this.LastModified = DateTime.MinValue;
this.storageAccount = CloudStorageAccount.FromConfigurationSetting(DataConfigurationKey);
this.blobStorage = storageAccount.CreateCloudBlobClient();
}
示例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();
}
示例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");
}
示例7: NeoServer
public NeoServer(NeoServerConfiguration configuration, CloudStorageAccount storageAccount)
: this(configuration,
new RoleEnvironmentWrapper(),
new CloudBlobClientWrapper(storageAccount.CreateCloudBlobClient()),
new FileSystem(),
new ZipHandler())
{}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例12: BlobOptimisticDataStore
public BlobOptimisticDataStore(CloudStorageAccount account, string containerName)
{
var blobClient = account.CreateCloudBlobClient();
blobContainer = blobClient.GetContainerReference(containerName.ToLower());
blobContainer.CreateIfNotExist();
blobReferences = new Dictionary<string, CloudBlob>();
}
示例13: AzureStorageClient
public AzureStorageClient(CloudStorageAccount account)
{
client = account.CreateCloudBlobClient();
client.DefaultDelimiter = "/";
container = client.GetContainerReference("documents");
container.CreateIfNotExist();
}
示例14: AzureBlobStore
internal AzureBlobStore(string accountName, string targetContainer, string accountKey)
{
_storageAccount = new CloudStorageAccount(new StorageCredentialsAccountAndKey(accountName, accountKey), true);
_blobStorage = _storageAccount.CreateCloudBlobClient();
_targetContainer = targetContainer;
CreateContainer();
}
示例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 });
}