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


C# CloudBlobContainer.Exists方法代码示例

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


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

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

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

示例3: BaseStorage

 /// <summary>Constructor establishes the connection</summary>
 /// <param name="containerName">The name of the container inside Azure</param>
 protected BaseStorage(string containerName)
 {
     var cloudStorageAccount = CloudStorageAccount.Parse(
         CloudConfigurationManager.GetSetting(BlobStorageConnectionStringKey));
     var cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient();
     _cloudBlobContainer = cloudBlobClient.GetContainerReference(containerName);
     if (!_cloudBlobContainer.Exists()) _cloudBlobContainer.CreateIfNotExists();
 }
开发者ID:vtimashkov,项目名称:O.Danheli,代码行数:10,代码来源:BaseStorage.cs

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

示例5: DoesContainerExist

 /// <summary>
 /// Whether the container exists or not
 /// </summary>
 /// <param name="container">A cloudblobcontainer object</param>
 /// <param name="options">Blob request option</param>
 /// <param name="operationContext">Operation context</param>
 /// <returns>True if the specific container exists, otherwise return false</returns>
 public bool DoesContainerExist(CloudBlobContainer container, BlobRequestOptions options, OperationContext operationContext)
 {
     if (null == container)
     {
         return false;
     }
     else
     {
         return container.Exists(options, operationContext);
     }
 }
开发者ID:NordPool,项目名称:azure-sdk-tools,代码行数:18,代码来源:StorageBlobManagement.cs

示例6: ResetContainer

        private void ResetContainer(CloudBlobContainer container)
        {
            if (!container.Exists()) return;

            Trace.WriteLine($"Ready to parse {container.Name} container");
            Trace.WriteLine("------------------------------------------------");

            var blobs = container.ListBlobs().ToList();

            var total = blobs.Count;
            var counter = 1;

            foreach (var blob in blobs)
            {
                if (blob is CloudBlobDirectory) continue;

                var cloudBlob = (CloudBlob)blob;

                var extension = Path.GetExtension(cloudBlob.Uri.AbsoluteUri);

                string contentType;
                _contentTypes.TryGetValue(extension, out contentType);
                if (string.IsNullOrEmpty(contentType)) continue;

                Trace.Write($"{counter++} of {total} : {cloudBlob.Name}");
                if (cloudBlob.Properties.ContentType == contentType)
                {
                    Trace.WriteLine($" ({cloudBlob.Properties.ContentType}) (skipped)");
                    continue;
                }

                cloudBlob.Properties.ContentType = contentType;
                cloudBlob.SetProperties();
                Trace.WriteLine($" ({cloudBlob.Properties.ContentType}) (reset)");
            }
        }
开发者ID:ppolyzos,项目名称:AzStorage.Utilities,代码行数:36,代码来源:BlobReset.cs


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