當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。