本文整理汇总了C#中Microsoft.WindowsAzure.StorageClient.CloudBlobContainer类的典型用法代码示例。如果您正苦于以下问题:C# CloudBlobContainer类的具体用法?C# CloudBlobContainer怎么用?C# CloudBlobContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CloudBlobContainer类属于Microsoft.WindowsAzure.StorageClient命名空间,在下文中一共展示了CloudBlobContainer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: MonitorCopy
/// <summary>
/// Taken from: http://blogs.msdn.com/b/windowsazurestorage/archive/2012/06/12/introducing-asynchronous-cross-account-copy-blob.aspx
/// </summary>
/// <param name="destContainer">The container to monitor</param>
public static void MonitorCopy(CloudBlobContainer destContainer)
{
var pendingCopy = true;
while (pendingCopy)
{
var destBlobList = destContainer.ListBlobs(true, BlobListingDetails.Copy);
foreach (var destBlob in destBlobList.Select(dest => dest as CloudBlob))
{
if (destBlob.CopyState == null)
{
Debug.WriteLine("BlobStorage.MonitorCopy: CopyState is null. Small sleep, then we assume it's done!");
Thread.Sleep(5000);
return;
}
switch (destBlob.CopyState.Status)
{
case CopyStatus.Failed:
case CopyStatus.Aborted:
Debug.WriteLine("BlobStorage.MonitorCopy: Copy Failed or Aborted; restarting copy");
destBlob.StartCopyFromBlob(destBlob.CopyState.Source);
break;
case CopyStatus.Success:
pendingCopy = false;
break;
}
}
Thread.Sleep(1000);
}
}
开发者ID:amido,项目名称:Amido.Testing,代码行数:37,代码来源:BlobStorage.cs
示例2: Sync
static void Sync(CloudBlobContainer container, string rootPath)
{
// iterate all files from storage
foreach (CloudBlob item in container.ListBlobs(new BlobRequestOptions() { UseFlatBlobListing = true })) {
try {
var localPath = Path.Combine(rootPath, item.Name);
if (File.Exists(localPath) && File.GetLastWriteTimeUtc(localPath).ToFileTime() > item.Properties.LastModifiedUtc.ToFileTime())
continue; // local file is more recent
if (!Directory.Exists(Path.GetDirectoryName(localPath)))
Directory.CreateDirectory(Path.GetDirectoryName(localPath));
for (var i = 0; i < RETRY_COUNT; i++) {
try {
using (var fs = File.Open(localPath, FileMode.Create)) {
item.DownloadToStream(fs);
break; // all OK
}
} catch (IOException) {
// retry again later
System.Threading.Thread.Sleep(SLEEPMS_ONFAIL);
}
//catch (UnauthorizedAccessException) {
// // ??? just catch this silently otherwise IIS will crash
//}
}
} catch (Exception ex) {
NLog.LogManager.GetLogger("optQuick").Error(string.Format("Unable to process path {0} => {1}", rootPath, item.Name));
NLog.LogManager.GetLogger("optQuick").Error(ex);
throw;
}
}
}
开发者ID:bogdan-litescu,项目名称:OpenTraits.QuickDeployService,代码行数:34,代码来源:QuickDeployService.cs
示例3: CreateIfNotExist
public void CreateIfNotExist(CloudBlobContainer cloudBlobContainer, bool isPublic = true)
{
cloudBlobContainer.CreateIfNotExist();
var permission = cloudBlobContainer.GetPermissions();
var blobContainerPermissions = new BlobContainerPermissions {PublicAccess = isPublic ? BlobContainerPublicAccessType.Container : BlobContainerPublicAccessType.Off};
cloudBlobContainer.SetPermissions(blobContainerPermissions);
}
开发者ID:rgardler,项目名称:dpp,代码行数:7,代码来源:BlobStorageWrapper.cs
示例4: StatelessAzureQueueWriter
public StatelessAzureQueueWriter(IEnvelopeStreamer streamer, CloudBlobContainer container, CloudQueue queue, string name)
{
_streamer = streamer;
_cloudBlob = container;
_queue = queue;
Name = name;
}
开发者ID:higheredgrowth,项目名称:lokad-cqrs,代码行数:7,代码来源:StatelessAzureQueueWriter.cs
示例5: Sync
public void Sync(string localPath, CloudBlobContainer blobContainer, IEnumerable<string> directoriesToExclude)
{
this._localPath = localPath;
this._container = blobContainer;
this._directoriesToExclude = directoriesToExclude;
if (Monitor.TryEnter(this._syncLock)) // avoid concurrent updates from starting on this instance
{
try
{
HashSet<string> umbracoSettings = new HashSet<string>();
HashSet<string> seen = new HashSet<string>();
HashSet<string> newCerts = new HashSet<string>();
this.SyncLocalToBlob(seen, umbracoSettings);
//Time to check on blob storge for updates to sync
seen = new HashSet<string>();
this.SyncBlobToLocal(seen, newCerts);
this.UpdateInstanceHostsFile();
this.UpdateUmbracoSettings(umbracoSettings);
this.UpdateSites(newCerts);
} //end sync try {} block
finally { Monitor.Exit(this._syncLock); }
}
else
{
//skip sync
}
}
开发者ID:Jeavon,项目名称:wa-accelerator-umbraco,代码行数:34,代码来源:Sync.cs
示例6: UploadBlob
private static void UploadBlob(CloudBlobContainer container, string blobName, string filename)
{
CloudBlob blob = container.GetBlobReference(blobName);
using (FileStream fileStream = File.OpenRead(filename))
blob.UploadFromStream(fileStream);
}
开发者ID:jonbgallant,项目名称:Neo4j.Azure.Server,代码行数:7,代码来源:Program.cs
示例7: AzureBlobRepository
public AzureBlobRepository(CloudStorageAccount storageAccount, CloudBlobClient blobClient, CloudBlobContainer blobContainer)
{
this._storageAccount = storageAccount;
this._blobClient = blobClient;
this._blobContainer = blobContainer;
_blobContainer.SetPermissions(GetPermissions());
}
开发者ID:bennygrub,项目名称:msl,代码行数:8,代码来源:AzureBlobRepository.cs
示例8: AzureDataCache
///<summary>Creates an AzureDataCache service.</summary>
///<param name="container">The CloudBlobContainer to read data from.</param>
///<param name="destination">The path to save the data. (on the local disk)</param>
public AzureDataCache(CloudBlobContainer container, string destination)
{
if (container == null) throw new ArgumentNullException("container");
if (destination == null) throw new ArgumentNullException("destination");
this.container = container;
LocalPath = destination;
}
开发者ID:Amichai,项目名称:Prax,代码行数:11,代码来源:AzureDataCache.cs
示例9: SaveToAzureBlob
/// <summary>
/// Save the data table to the given azure blob. This will overwrite an existing blob.
/// </summary>
/// <param name="table">instance of table to save</param>
/// <param name="container">conatiner</param>
/// <param name="blobName">blob name</param>
public static void SaveToAzureBlob(this DataTable table, CloudBlobContainer container, string blobName)
{
var blob = container.GetBlobReference(blobName);
using (BlobStream stream = blob.OpenWrite())
using (TextWriter writer = new StreamWriter(stream))
{
table.SaveToStream(writer);
}
}
开发者ID:bmegias,项目名称:DataTable,代码行数:15,代码来源:AzureDataTableExtensions.cs
示例10: AzureMonthViewStore
public AzureMonthViewStore(CloudBlobContainer viewContainer)
{
if (viewContainer == null)
{
throw new ArgumentNullException("viewContainer");
}
this.viewContainer = viewContainer;
}
开发者ID:ploeh,项目名称:CQRSonAzureDemo,代码行数:9,代码来源:AzureMonthViewStore.cs
示例11: CreateBlobNotExistsTaskRunner
public override TaskRunner CreateBlobNotExistsTaskRunner(CloudBlobContainer blobContainer, FileInformation fileInfo)
{
this._statistics.BlobNotExistCount++;
return new SingleActionTaskRunner(() =>
{
_messageBus.Publish(new FileProgressedMessage(fileInfo.FullPath, 0));
_fileSystem.DeleteFile(fileInfo.FullPath);
_messageBus.Publish(new FileProgressedMessage(fileInfo.FullPath, 1));
});
}
开发者ID:devsda0,项目名称:AzureBackup,代码行数:10,代码来源:DownloadDeleteSyncronizationProvider.cs
示例12: ContainerTreeNode
public ContainerTreeNode(CloudBlobContainer container)
: this()
{
Container = container;
foreach (var blob in container.ListBlobs().OfType<CloudBlob>())
Nodes.Add(new BlobTreeNode(blob));
Text = container.Name;
}
开发者ID:caseywatson,项目名称:AzureStorageDemo,代码行数:10,代码来源:ContainerTreeNode.cs
示例13: Initialize
private void Initialize(CloudBlobContainer container)
{
if (container == null)
{
throw new ArgumentNullException("container");
}
_container = container;
AzureBlobs = new Collection<AzureBlobInfo>();
}
开发者ID:andreychizhov,项目名称:microsoft-aspnet-samples,代码行数:10,代码来源:AzureBlobStorageMultipartProvider.cs
示例14: 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
示例15: MyClassInitialize
public static void MyClassInitialize(TestContext testContext)
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(DevConnectionString);
blobClient = storageAccount.CreateCloudBlobClient();
container = blobClient.GetContainerReference(TestContainerName);
container.CreateIfNotExist();
}
开发者ID:phillipknauss,项目名称:CqrsSiteEngine,代码行数:7,代码来源:AzureTapeStreamTest.cs
示例16: 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
示例17: OnStart
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
DiagnosticMonitor.Start("DiagnosticsConnectionString");
// For information on handling configuration changes
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
RoleEnvironment.Changing += RoleEnvironmentChanging;
// read storage account configuration settings
CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter)
=> configSetter(RoleEnvironment.GetConfigurationSettingValue(configName)));
var storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
// initialize blob storage
CloudBlobClient blobStorage = storageAccount.CreateCloudBlobClient();
container = blobStorage.GetContainerReference("converteddata");
// initialize queue storage
CloudQueueClient queueStorage = storageAccount.CreateCloudQueueClient();
queue = queueStorage.GetQueueReference("workercommands");
Trace.TraceInformation("Creating container and queue...");
bool storageInitialized = false;
while (!storageInitialized)
{
try
{
// create the blob container and allow public access
container.CreateIfNotExist();
var permissions = container.GetPermissions();
permissions.PublicAccess = BlobContainerPublicAccessType.Container;
container.SetPermissions(permissions);
// create the message queue
queue.CreateIfNotExist();
storageInitialized = true;
}
catch (StorageClientException e)
{
if (e.ErrorCode == StorageErrorCode.TransportError)
{
Trace.TraceError("Storage services initialization failure. "
+ "Check your storage account configuration settings. If running locally, "
+ "ensure that the Development Storage service is running. Message: '{0}'", e.Message);
Thread.Sleep(5000);
}
else
{
throw;
}
}
}
return base.OnStart();
}
开发者ID:aytacozkan,项目名称:OGDI-DataLab,代码行数:60,代码来源:WorkerRole.cs
示例18: 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
示例19: OnStart
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
// read storage account configuration settings
CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
{
configSetter(RoleEnvironment.GetConfigurationSettingValue(configName));
});
var storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
// initialize blob storage
var blobStorage = storageAccount.CreateCloudBlobClient();
blobContainer = blobStorage.GetContainerReference("guestbookpics");
// initialize queue storage
var queueStorage = storageAccount.CreateCloudQueueClient();
queue = queueStorage.GetQueueReference("guestbookthumbs");
Trace.TraceInformation("Creating container and queue...");
bool storageInitialized = false;
while (!storageInitialized)
{
try
{
// create the blob container and allow public access
this.blobContainer.CreateIfNotExist();
var permissions = this.blobContainer.GetPermissions();
permissions.PublicAccess = BlobContainerPublicAccessType.Container;
this.blobContainer.SetPermissions(permissions);
// create the message queue(s)
this.queue.CreateIfNotExist();
storageInitialized = true;
}
catch (StorageClientException e)
{
if (e.ErrorCode == StorageErrorCode.TransportError)
{
Trace.TraceError(
"Storage services initialization failure. "
+ "Check your storage account configuration settings. If running locally, "
+ "ensure that the Development Storage service is running. Message: '{0}'",
e.Message);
System.Threading.Thread.Sleep(5000);
}
else
{
throw;
}
}
}
return base.OnStart();
}
开发者ID:ChrisKoenig,项目名称:Azure-MvcGuestbook,代码行数:59,代码来源:WorkerRole.cs
示例20: AzureStorageClient
public AzureStorageClient(CloudStorageAccount account)
{
client = account.CreateCloudBlobClient();
client.DefaultDelimiter = "/";
container = client.GetContainerReference("documents");
container.CreateIfNotExist();
}
开发者ID:Amichai,项目名称:Prax,代码行数:8,代码来源:AzureStorageClient.cs
注:本文中的Microsoft.WindowsAzure.StorageClient.CloudBlobContainer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论