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


C# CloudBlobContainer.CreateIfNotExists方法代码示例

本文整理汇总了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 });
 }
开发者ID:jackyzhong123,项目名称:apidemo,代码行数:7,代码来源:BlobHelper.cs

示例2: ImageStore

        public ImageStore()
        {
            _client = Account.CreateCloudBlobClient();
            _container = _client.GetContainerReference(ContainerName);

            _container.CreateIfNotExists(BlobContainerPublicAccessType.Blob);
        }
开发者ID:brporter,项目名称:slackmeme,代码行数:7,代码来源:ImageStore.cs

示例3: AzureFileSystem

 public AzureFileSystem(String connectionString, String containerName)
 {
     CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
     CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
     container = blobClient.GetContainerReference(containerName.ToLower());
     container.CreateIfNotExists();
 }
开发者ID:Fedorm,项目名称:core-master,代码行数:7,代码来源:AzureFileSystem.cs

示例4: GetClientAndReference

 private void GetClientAndReference()
 {    
     var account = CloudStorageAccount.Parse(_source.ConnectionString);
     var client = account.CreateCloudBlobClient();
     _containerReference = client.GetContainerReference(_source.ContainerName);
     _containerReference.CreateIfNotExists();
 }
开发者ID:kgeis,项目名称:BeeHive,代码行数:7,代码来源:AzureLockStore.cs

示例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);
            }
        }
开发者ID:victorhugom,项目名称:AzureApiHelpers,代码行数:34,代码来源:BlobStorage.cs

示例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();
        }
开发者ID:jcflore3,项目名称:TCWAdminPortal,代码行数:34,代码来源:WorkerRole.cs

示例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();
        }
开发者ID:phongha,项目名称:myprojects,代码行数:35,代码来源:WorkerRoleB.cs

示例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();
        }
开发者ID:techieshravan,项目名称:azure,代码行数:26,代码来源:WorkerRole.cs

示例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);
        }
开发者ID:Quintoh,项目名称:Konstprojektet,代码行数:32,代码来源:HomeController.cs

示例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;
        }
开发者ID:kbxkb,项目名称:ContosoSportsLeague,代码行数:31,代码来源:AzureStorageMethods.cs

示例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);
                        }
                    }
                }
            }
        }
开发者ID:crb02005,项目名称:RandomTables,代码行数:30,代码来源:BlobProvider.cs

示例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");
            }
        }
开发者ID:oumartraore,项目名称:SupStorage,代码行数:28,代码来源:BlobManager.cs

示例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 
            }

        }
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:25,代码来源:AzureFileSystem.cs

示例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();
 }
开发者ID:danvy,项目名称:sigfox,代码行数:59,代码来源:EventProcessor.cs

示例15: BlobOptimisticDataStore

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

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


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