public CloudStorage(string storageConnectionString, string blobContainer, bool createIfNotExists = true) { if (string.IsNullOrWhiteSpace(blobContainer)) { throw new Exception("O parâmetro 'blobContainer' não pode ser nulo, vazio ou em branco."); } if (string.IsNullOrWhiteSpace(storageConnectionString)) { throw new Exception("O parâmetro 'storageConnectionString' não pode ser nulo, vazio ou em branco."); } if (blobContainer.Any(char.IsUpper)) { throw new Exception("O parâmetro 'storageConnectionString' não pode conter caracteres em caixa alta."); } StorageAccount = CloudStorageAccount.Parse(storageConnectionString); BlobClient = StorageAccount.CreateCloudBlobClient(); BlobContainer = BlobClient.GetContainerReference(blobContainer); if (createIfNotExists) { BlobContainer.CreateIfNotExists(); } }
public void CreateContainer() { BlobContainer = _blobClient.GetContainerReference(_catalog); // create it if it does not exist BlobContainer.CreateIfNotExists(); }
protected void SetContainer() { BlobContainer = BlobClient.GetContainerReference(ContainerName); if (CreateIfNotExists) { BlobContainer.CreateIfNotExists(); } }
public void Initialize() { StorageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString")); BlobClient = StorageAccount.CreateCloudBlobClient(); //TODO: Change to appropriate container name BlobContainer = BlobClient.GetContainerReference("mycontainer"); //BlobContainer = BlobClient.GetContainerReference("pdflobs"); BlobContainer.CreateIfNotExists(); }
private void ClearAllBlobSecrets() { BlobContainer.CreateIfNotExists(); var blobs = BlobContainer.ListBlobs(prefix: TestSiteName.ToLowerInvariant(), useFlatBlobListing: true); foreach (IListBlobItem blob in blobs) { BlobContainer.GetBlockBlobReference(((CloudBlockBlob)blob).Name).DeleteIfExists(); } }
protected void SetContainer(string containerName) { ContainerName = containerName; BlobContainer = BlobClient.GetContainerReference(containerName); if (CreateIfNotExists) { BlobContainer.CreateIfNotExists(); } }