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


C# CloudBlobContainer.CreateIfNotExist方法代码示例

本文整理汇总了C#中Microsoft.WindowsAzure.StorageClient.CloudBlobContainer.CreateIfNotExist方法的典型用法代码示例。如果您正苦于以下问题:C# CloudBlobContainer.CreateIfNotExist方法的具体用法?C# CloudBlobContainer.CreateIfNotExist怎么用?C# CloudBlobContainer.CreateIfNotExist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.WindowsAzure.StorageClient.CloudBlobContainer的用法示例。


在下文中一共展示了CloudBlobContainer.CreateIfNotExist方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: AzureHelper

 static AzureHelper()
 {
     var cloudStorageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=http;AccountName=mintchipmarket;AccountKey=6wtpT0uW75m2LsThfROjp+cMA5zWx8VllZhJ5tM7kPAZZlIbPZ0t7pIXkO0s0AnzZ4sWMnl+rc5+1KjlNWKlfA==");
     var blobClient = new CloudBlobClient(cloudStorageAccount.BlobEndpoint, cloudStorageAccount.Credentials);
     _container = blobClient.GetContainerReference("files");
     _container.CreateIfNotExist();
     _container.SetPermissions(new BlobContainerPermissions() { PublicAccess = BlobContainerPublicAccessType.Off });
 }
开发者ID:StevenGilligan,项目名称:MintChipMarket,代码行数:8,代码来源:AzureHelper.cs

示例8: BlobOptimisticDataStore

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

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

示例9: AzureStorageClient

        public AzureStorageClient(CloudStorageAccount account)
        {
            client = account.CreateCloudBlobClient();
            client.DefaultDelimiter = "/";

            container = client.GetContainerReference("documents");
            container.CreateIfNotExist();
        }
开发者ID:Amichai,项目名称:Prax,代码行数:8,代码来源:AzureStorageClient.cs

示例10: 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 });
 }
开发者ID:twopieman,项目名称:PictureService,代码行数:11,代码来源:PictureService.svc.cs

示例11: AzureSystemEventStore

 public AzureSystemEventStore()
 {
     Streamer = new EventStreamer(new EventSerializer(MessagesProvider.GetKnownEventTypes()));
     CloudStorageAccount storageAccount = CloudStorageAccount.Parse(Settings.Default.AzureConnectionString);
     blobClient = storageAccount.CreateCloudBlobClient();
     container = blobClient.GetContainerReference(Settings.Default.AzureContainerName);
     container.CreateIfNotExist();
 }
开发者ID:stemarie,项目名称:CqrsSiteEngine,代码行数:8,代码来源:AzureSystemEventStore.cs

示例12: Azure_Stream_Factory

        public Azure_Stream_Factory(CloudStorageAccount account, string container_Name)
        {
            _container_Name = container_Name;

            _blobClient = account.CreateCloudBlobClient();

            container = _blobClient.GetContainerReference(container_Name);
            container.CreateIfNotExist();
        }
开发者ID:valeriob,项目名称:BPlusTreeStream,代码行数:9,代码来源:BPlusTree_Azure.cs

示例13: AzureTapeStream

        public AzureTapeStream(string name, string connectionString, string containerName, ITapeStreamSerializer serializer)
        {
            _serializer = serializer;

            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
            blobClient = storageAccount.CreateCloudBlobClient();
            container = blobClient.GetContainerReference(containerName);
            container.CreateIfNotExist();

            _blob = container.GetBlobReference(name);
        }
开发者ID:stemarie,项目名称:CqrsSiteEngine,代码行数:11,代码来源:AzureTapeStream.cs

示例14: AzureBlobFileRepository

        public AzureBlobFileRepository(IConfigSettings configSettings)
        {
            var setting = configSettings.Get("StorageConnectionString");
            containerName = configSettings.Get("BlobContainerName");
            storageAccount = CloudStorageAccount.Parse(setting);
            blobClient = storageAccount.CreateCloudBlobClient();
            container = blobClient.GetContainerReference(containerName.ToLower());

            container.CreateIfNotExist();
            container.SetPermissions(new BlobContainerPermissions
            {
                PublicAccess = BlobContainerPublicAccessType.Blob
            });
        }
开发者ID:Vintharas,项目名称:FunnelWeb,代码行数:14,代码来源:AzureBlobFileRepository.cs

示例15: Setup

        public void Setup()
        {
            _name = Guid.NewGuid().ToString().ToLowerInvariant();
            CloudStorageAccount cloudStorageAccount = ConnectionConfig.StorageAccount;
            var cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient();
            var documentStrategy = new DocumentStrategy(_name);
            _store = new AzureDocumentStore(documentStrategy, cloudBlobClient);

            _container = cloudBlobClient.GetBlobDirectoryReference(_name).Container;
            _container.CreateIfNotExist();

            _sampleDocContainer = cloudBlobClient.GetBlobDirectoryReference(_name).Container;
            _sampleDocContainer.CreateIfNotExist();
        }
开发者ID:mojamcpds,项目名称:lokad-cqrs-1,代码行数:14,代码来源:AzureDocumentStoreTest.cs


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