本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer.Create方法的典型用法代码示例。如果您正苦于以下问题:C# CloudBlobContainer.Create方法的具体用法?C# CloudBlobContainer.Create怎么用?C# CloudBlobContainer.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer
的用法示例。
在下文中一共展示了CloudBlobContainer.Create方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialise
/// <summary>
/// Occurs when a storage provider operation has completed.
/// </summary>
//public event EventHandler<StorageProviderEventArgs> StorageProviderOperationCompleted;
#endregion
// Initialiser method
private void Initialise(string storageAccount, string containerName)
{
if (String.IsNullOrEmpty(containerName))
throw new ArgumentException("You must provide the base Container Name", "containerName");
ContainerName = containerName;
_account = CloudStorageAccount.Parse(storageAccount);
_blobClient = _account.CreateCloudBlobClient();
_container = _blobClient.GetContainerReference(ContainerName);
try
{
_container.FetchAttributes();
}
catch (StorageException)
{
Trace.WriteLine(string.Format("Create new container: {0}", ContainerName), "Information");
_container.Create();
// set new container's permissions
// Create a permission policy to set the public access setting for the container.
BlobContainerPermissions containerPermissions = new BlobContainerPermissions();
// The public access setting explicitly specifies that the container is private,
// so that it can't be accessed anonymously.
containerPermissions.PublicAccess = BlobContainerPublicAccessType.Off;
//Set the permission policy on the container.
_container.SetPermissions(containerPermissions);
}
}
示例2: BlobContainer
public BlobContainer(string name)
{
// hämta connectionsträngen från config // RoleEnviroment bestämmer settingvalue runtime
//var connectionString = RoleEnvironment.GetConfigurationSettingValue("PhotoAppStorage");
//var connectionString = CloudConfigurationManager.GetSetting("CloudStorageApp");
// hämtar kontot utfrån connectionsträngens värde
//var account = CloudStorageAccount.Parse(connectionString);
//var account = CloudStorageAccount.DevelopmentStorageAccount;
var cred = new StorageCredentials("jholm",
"/bVipQ2JxjWwYrZQfHmzhaBx1p1s8BoD/wX6VWOmg4/gpVo/aALrjsDUKqzXsFtc9utepPqe65NposrXt9YsyA==");
var account = new CloudStorageAccount(cred, true);
// skapar en blobclient
_client = account.CreateCloudBlobClient();
m_BlobContainer = _client.GetContainerReference(name);
// Om det inte finns någon container med det namnet
if (!m_BlobContainer.Exists())
{
// Skapa containern
m_BlobContainer.Create();
var permissions = new BlobContainerPermissions()
{
PublicAccess = BlobContainerPublicAccessType.Blob
};
// Sätter public access till blobs
m_BlobContainer.SetPermissions(permissions);
}
}
示例3: InstanciateStorageContainer
private void InstanciateStorageContainer(string formattedStorageContainerName)
{
if ((_blobContainer == null) || (_blobContainer.Name != formattedStorageContainerName))
{
var cloudStorageAccount = CloudStorageAccount.Parse(StorageConnectionString);
var cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient();
_blobContainer = cloudBlobClient.GetContainerReference(formattedStorageContainerName);
if (!_blobContainer.Exists())
{
try
{
_blobContainer.Create();
while (!_blobContainer.Exists())
Thread.Sleep(100);
}
catch (StorageException storageException)
{
WriteDebugError(String.Format("NLog.AzureStorage - Failed to create Azure Storage Blob Container '{0}' - Storage Exception: {1} {2}", formattedStorageContainerName, storageException.Message, GetStorageExceptionHttpStatusMessage(storageException)));
throw;
}
}
}
}
示例4: Create
public static void Create(string account, string key, string containerName, bool publicAccess)
{
if (string.IsNullOrEmpty(containerName))
return;
CloudBlobClient blobClient = Client.GetBlobClient(account, key);
Uri uri = new Uri(string.Format(blobClient.BaseUri + "{0}", containerName));
CloudBlobContainer cont = new CloudBlobContainer(uri, blobClient.Credentials);
cont.Create();
if (publicAccess)
{
BlobContainerPermissions permissions = new BlobContainerPermissions();
permissions.PublicAccess = BlobContainerPublicAccessType.Container;
cont.SetPermissions(permissions);
}
}
示例5: BlobTriggerTests
public BlobTriggerTests()
{
_timesProcessed = 0;
RandomNameResolver nameResolver = new RandomNameResolver();
_hostConfiguration = new JobHostConfiguration()
{
NameResolver = nameResolver,
TypeLocator = new FakeTypeLocator(typeof(BlobTriggerTests)),
};
_storageAccount = CloudStorageAccount.Parse(_hostConfiguration.StorageConnectionString);
CloudBlobClient blobClient = _storageAccount.CreateCloudBlobClient();
_testContainer = blobClient.GetContainerReference(nameResolver.ResolveInString(ContainerName));
Assert.False(_testContainer.Exists());
_testContainer.Create();
}
示例6: Initialise
// Initialiser method
private void Initialise(string containerName)
{
if (String.IsNullOrEmpty(containerName))
throw new ArgumentException("You must provide the base Container Name", "containerName");
ContainerName = containerName;
if (StorageProviderConfiguration.Mode == Modes.Debug)
{
_account = CloudStorageAccount.DevelopmentStorageAccount;
_blobClient = _account.CreateCloudBlobClient();
_blobClient.ServerTimeout = new TimeSpan(0, 0, 0, 5);
}
else
{
_account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("FTP2Azure.StorageAccount"));
_blobClient = _account.CreateCloudBlobClient();
_blobClient.ServerTimeout = new TimeSpan(0, 0, 0, 5);
}
_container = _blobClient.GetContainerReference(ContainerName);
try
{
_container.FetchAttributes();
}
catch (StorageException)
{
Trace.WriteLine(string.Format("Create new container: {0}", ContainerName), "Information");
_container.Create();
// set new container's permissions
// Create a permission policy to set the public access setting for the container.
BlobContainerPermissions containerPermissions = new BlobContainerPermissions();
// The public access setting explicitly specifies that the container is private,
// so that it can't be accessed anonymously.
containerPermissions.PublicAccess = BlobContainerPublicAccessType.Off;
//Set the permission policy on the container.
_container.SetPermissions(containerPermissions);
}
}