本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer.CreateIfNotExists方法的典型用法代码示例。如果您正苦于以下问题:C# CloudBlobContainer.CreateIfNotExists方法的具体用法?C# CloudBlobContainer.CreateIfNotExists怎么用?C# CloudBlobContainer.CreateIfNotExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer
的用法示例。
在下文中一共展示了CloudBlobContainer.CreateIfNotExists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeContainer
public void InitializeContainer(string container)
{
var blobClient = StorageAccount.CreateCloudBlobClient();
blobContainer = blobClient.GetContainerReference(container);
blobContainer.CreateIfNotExists();
blobContainer.SetPermissions(new BlobContainerPermissions() { PublicAccess = BlobContainerPublicAccessType.Blob });
}
示例2: ImageStore
public ImageStore()
{
_client = Account.CreateCloudBlobClient();
_container = _client.GetContainerReference(ContainerName);
_container.CreateIfNotExists(BlobContainerPublicAccessType.Blob);
}
示例3: AzureFileSystem
public AzureFileSystem(String connectionString, String containerName)
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
container = blobClient.GetContainerReference(containerName.ToLower());
container.CreateIfNotExists();
}
示例4: GetClientAndReference
private void GetClientAndReference()
{
var account = CloudStorageAccount.Parse(_source.ConnectionString);
var client = account.CreateCloudBlobClient();
_containerReference = client.GetContainerReference(_source.ContainerName);
_containerReference.CreateIfNotExists();
}
示例5: BlobStorage
public BlobStorage(BlobSettings appSettings)
{
try
{
if (appSettings.ImageSize != null)
ResizeLayer = new ResizeLayer(appSettings.ImageSize, ResizeMode.Min);
UploadThumbnail = appSettings.UploadThumbnail;
StorageAccountName = appSettings.StorageAccountName;
StorageAccountAccessKey = appSettings.StorageAccountAccessKey;
// Create a blob client and retrieve reference to images container
BlobClient = StorageAccount.CreateCloudBlobClient();
Container = BlobClient.GetContainerReference(appSettings.ContainerName);
// Create the "images" container if it doesn't already exist.
if (Container.CreateIfNotExists())
{
// Enable public access on the newly created "images" container
Container.SetPermissions(
new BlobContainerPermissions
{
PublicAccess =
BlobContainerPublicAccessType.Blob
});
}
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
}
示例6: OnStart
public override bool OnStart()
{
// Set the maximum number of concurrent connections.
ServicePointManager.DefaultConnectionLimit = 12;
// Read database connection string and open database.
var dbConnString = CloudConfigurationManager.GetSetting("TCWAdminPortalDbConnectionString");
_dbContext = new TCWAdminContext(dbConnString);
// Open storage account using credentials from .cscfg file.
var storageAccount = CloudStorageAccount.Parse
(RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString"));
Trace.TraceInformation("Creating images blob container");
var blobClient = storageAccount.CreateCloudBlobClient();
_imagesBlobContainer = blobClient.GetContainerReference("images");
if (_imagesBlobContainer.CreateIfNotExists())
{
// Enable public access on the newly created "images" container.
_imagesBlobContainer.SetPermissions(
new BlobContainerPermissions
{
PublicAccess = BlobContainerPublicAccessType.Blob
});
}
Trace.TraceInformation("Creating images queue");
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
_imagesQueue = queueClient.GetQueueReference("images");
_imagesQueue.CreateIfNotExists();
Trace.TraceInformation("Storage initialized");
return base.OnStart();
}
示例7: OnStart
public override bool OnStart()
{
ServicePointManager.DefaultConnectionLimit = Environment.ProcessorCount;
// Read storage account configuration settings
ConfigureDiagnostics();
Trace.TraceInformation("Initializing storage account in worker role B");
var storageAccount = Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString"));
// Initialize queue storage
Trace.TraceInformation("Creating queue client.");
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
sendEmailQueue = queueClient.GetQueueReference("azuremailqueue");
subscribeQueue = queueClient.GetQueueReference("azuremailsubscribequeue");
// Initialize blob storage
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
blobContainer = blobClient.GetContainerReference("azuremailblobcontainer");
// Initialize table storage
var tableClient = storageAccount.CreateCloudTableClient();
mailingListTable = tableClient.GetTableReference("mailinglist");
messageTable = tableClient.GetTableReference("message");
messagearchiveTable = tableClient.GetTableReference("messagearchive");
Trace.TraceInformation("WorkerB: Creating blob container, queue, tables, if they don't exist.");
blobContainer.CreateIfNotExists();
sendEmailQueue.CreateIfNotExists();
subscribeQueue.CreateIfNotExists();
this.messageTable.CreateIfNotExists();
this.mailingListTable.CreateIfNotExists();
this.messagearchiveTable.CreateIfNotExists();
return base.OnStart();
}
示例8: OnStart
public override bool OnStart()
{
ServicePointManager.DefaultConnectionLimit = 12;
var dbConnString = CloudConfigurationManager.GetSetting("PhotoGalleryDbConnectionString");
db = new PhotoGalleryContext(dbConnString);
var storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString"));
Trace.TraceInformation("Creating images blob container");
var blobClient = storageAccount.CreateCloudBlobClient();
imagesBlobContainer = blobClient.GetContainerReference("images");
if (imagesBlobContainer.CreateIfNotExists())
{
imagesBlobContainer.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob });
}
Trace.TraceInformation("Creating images queue");
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
imagesQueue = queueClient.GetQueueReference("images");
imagesQueue.CreateIfNotExists();
Trace.TraceInformation("Storage initialized");
return base.OnStart();
}
示例9: HomeController
public HomeController()
{
storageAccount = CloudStorageAccount.Parse(
ConfigurationManager.AppSettings["StorageConnectionString"]);
tableClient = storageAccount.CreateCloudTableClient();
table = tableClient.GetTableReference("fouramigos");
table.CreateIfNotExists();
blobClient = storageAccount.CreateCloudBlobClient();
container = blobClient.GetContainerReference("fouramigos");
container.CreateIfNotExists();
BlobContainerPermissions permissions = container.GetPermissions();
permissions.PublicAccess = BlobContainerPublicAccessType.Container;
container.SetPermissions(permissions);
//lägga till nya
//var tablemodels = new TableModel("Brutus", "Uggla") { Location = "T4", Description="Uggla i träd", Type="Foto" };
//var tablemodels1 = new TableModel("brutus", "Örn") { Location = "T4", Description="Örn som flyger", Type = "Foto" };
//var opreation = TableOperation.Insert(tablemodels);
//var operation2 = TableOperation.Insert(tablemodels1);
//table.Execute(opreation);
//table.Execute(operation2);
}
示例10: UploadPdfToBlob
/// <summary>
/// Upload the generated receipt Pdf to Blob storage.
/// </summary>
/// <param name="file">Byte array containig the Pdf file contents to be uploaded.</param>
/// <param name="fileName">The desired filename of the uploaded file.</param>
/// <returns></returns>
public string UploadPdfToBlob(byte[] file, string fileName)
{
// Create the blob client.
blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve a reference to a container.
blobContainer = blobClient.GetContainerReference(receiptBlobName);
// Create the container if it doesn't already exist.
blobContainer.CreateIfNotExists(BlobContainerPublicAccessType.Blob);
string fileUri = string.Empty;
CloudBlockBlob blockBlob = blobContainer.GetBlockBlobReference(fileName);
using (var stream = new MemoryStream(file))
{
// Upload the in-memory Pdf file to blob storage.
blockBlob.UploadFromStream(stream);
}
fileUri = blockBlob.Uri.ToString();
return fileUri;
}
示例11: BlobFileProvider
public BlobFileProvider(IEnumerable<string> locations)
: base()
{
_storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);
_blobClient = _storageAccount.CreateCloudBlobClient();
_container = _blobClient.GetContainerReference("data");
_container.CreateIfNotExists();
_strings = new List<string>();
foreach(string location in locations) {
foreach (IListBlobItem item in _container.ListBlobs(location,true))
{
if (item.GetType() == typeof(CloudBlockBlob))
{
CloudBlockBlob blob = (CloudBlockBlob)item;
string text;
using (var memoryStream = new MemoryStream())
{
blob.DownloadToStream(memoryStream);
text = Encoding.UTF8.GetString(memoryStream.ToArray());
if (text[0] == _byteOrderMarkUtf8[0])
{
text= text.Remove(0,_byteOrderMarkUtf8.Length);
}
_strings.Add(text);
}
}
}
}
}
示例12: BlobManager
public BlobManager(){
try
{
storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString"));
blobClient = storageAccount.CreateCloudBlobClient();
container = blobClient.GetContainerReference("supstorage");
container.CreateIfNotExists();
}
catch (ArgumentNullException)
{
Trace.TraceInformation("CloudStorageAccount Exception null ou vide");
// Use Application Local Storage Account String
}
catch (NullReferenceException)
{
Trace.TraceInformation("CloudBlobClient Or CloudBlobContainer Exception");
// Create Container
}
catch (FormatException)
{
Trace.TraceInformation("CloudStorageAccount Exception Connection String Invalid");
}
catch (ArgumentException)
{
Trace.TraceInformation("CloudStorageAccount Exception connectionString ne peut pas être analysée");
}
}
示例13: AzureFileSystem
public AzureFileSystem(string containerName, string root, bool isPrivate, CloudStorageAccount storageAccount) {
// Setup the connection to custom storage accountm, e.g. Development Storage
_storageAccount = storageAccount;
ContainerName = containerName;
_root = String.IsNullOrEmpty(root) ? "": root + "/";
_absoluteRoot = Combine(Combine(_storageAccount.BlobEndpoint.AbsoluteUri, containerName), _root);
//using ( new HttpContextWeaver() )
{
BlobClient = _storageAccount.CreateCloudBlobClient();
// Get and create the container if it does not exist
// The container is named with DNS naming restrictions (i.e. all lower case)
Container = BlobClient.GetContainerReference(ContainerName);
Container.CreateIfNotExists();
Container.SetPermissions(isPrivate
? new BlobContainerPermissions
{PublicAccess = BlobContainerPublicAccessType.Off}
: new BlobContainerPermissions
{PublicAccess = BlobContainerPublicAccessType.Blob}); // deny listing
}
}
示例14: OpenAsync
public async Task OpenAsync(PartitionContext context)
{
if (!WebJobsHelper.RunAsWebJobs)
Console.WriteLine(string.Format("EventProcessor initialization. Partition: '{0}', Offset: '{1}'",
context.Lease.PartitionId, context.Lease.Offset));
partitionContext = context;
var retries = 3;
while (retries > 0)
{
var s = string.Empty;
try
{
retries--;
s = "storage";
storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["SigfoxDemoStorage"].ConnectionString);
var blobClient = storageAccount.CreateCloudBlobClient();
blobContainer = blobClient.GetContainerReference("device");
blobContainer.SetPermissions(new BlobContainerPermissions() { PublicAccess = BlobContainerPublicAccessType.Off });
blobContainer.CreateIfNotExists();
s = "cache";
cacheConnection = await ConnectionMultiplexer.ConnectAsync(ConfigurationManager.ConnectionStrings["SigfoxDemoCache"].ConnectionString);
cacheDatabase = cacheConnection.GetDatabase();
s = "database";
sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SigfoxDemoDatabase"].ConnectionString);
sqlConnection.Open();
sqlCommand = new SqlCommand("InsertMessage", sqlConnection) { CommandType = CommandType.StoredProcedure };
sqlCommand.Parameters.Add(new SqlParameter("@Device", SqlDbType.VarChar));
sqlCommand.Parameters.Add(new SqlParameter("@Data", SqlDbType.VarChar));
sqlCommand.Parameters.Add(new SqlParameter("@Mode", SqlDbType.TinyInt));
sqlCommand.Parameters.Add(new SqlParameter("@Periode", SqlDbType.TinyInt));
sqlCommand.Parameters.Add(new SqlParameter("@FrameType", SqlDbType.TinyInt));
sqlCommand.Parameters.Add(new SqlParameter("@Battery", SqlDbType.Float));
sqlCommand.Parameters.Add(new SqlParameter("@Temperature", SqlDbType.Float));
sqlCommand.Parameters.Add(new SqlParameter("@Humidity", SqlDbType.Float));
sqlCommand.Parameters.Add(new SqlParameter("@ILS", SqlDbType.Bit));
sqlCommand.Parameters.Add(new SqlParameter("@Light", SqlDbType.Float));
sqlCommand.Parameters.Add(new SqlParameter("@Version", SqlDbType.VarChar));
sqlCommand.Parameters.Add(new SqlParameter("@AlertCount", SqlDbType.Int));
sqlCommand.Parameters.Add(new SqlParameter("@TimeStamp", SqlDbType.DateTime));
sqlCommand.Parameters.Add(new SqlParameter("@Duplicate", SqlDbType.Bit));
sqlCommand.Parameters.Add(new SqlParameter("@Signal", SqlDbType.Float));
sqlCommand.Parameters.Add(new SqlParameter("@Station", SqlDbType.VarChar));
sqlCommand.Parameters.Add(new SqlParameter("@AvgSignal", SqlDbType.Float));
sqlCommand.Parameters.Add(new SqlParameter("@Latitude", SqlDbType.Float));
sqlCommand.Parameters.Add(new SqlParameter("@Longitude", SqlDbType.Float));
sqlCommand.Parameters.Add(new SqlParameter("@Rssi", SqlDbType.Float));
sqlCommand.Parameters.Add(new SqlParameter("@SeqNumber", SqlDbType.Int));
retries = 0;
}
catch (Exception e)
{
Console.Error.WriteLine("Error opening destination Event Hub: " + e.Message + "(" + s + ")");
if (retries == 0)
throw;
}
}
checkpointStopWatch = new Stopwatch();
checkpointStopWatch.Start();
}
示例15: BlobOptimisticDataStore
public BlobOptimisticDataStore(CloudStorageAccount account, string containerName)
{
var blobClient = account.CreateCloudBlobClient();
blobContainer = blobClient.GetContainerReference(containerName.ToLower());
blobContainer.CreateIfNotExists();
blobReferences = new Dictionary<string, ICloudBlob>();
}