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


C# CloudBlobContainer.Create方法代码示例

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

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

示例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;
                    }
                }
            }
        }
开发者ID:nickheppleston,项目名称:NLog.AzureStorage,代码行数:26,代码来源:AzureBlobStorageProxy.cs

示例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);
			}
		}
开发者ID:yungmone,项目名称:azurestorageexplorer,代码行数:17,代码来源:Container.cs

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

示例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);
            }
        }
开发者ID:nexbit,项目名称:FTP2Azure,代码行数:43,代码来源:AzureBlobStorageProvider.cs


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