public BlobClient(string connectionString, string containerName, string accountName, string accountKey) { if (string.IsNullOrWhiteSpace(connectionString)) { throw new System.ArgumentException($"'{nameof(connectionString)}' cannot be null or whitespace", nameof(connectionString)); } if (string.IsNullOrWhiteSpace(containerName)) { throw new System.ArgumentException($"'{nameof(containerName)}' cannot be null or whitespace", nameof(containerName)); } if (string.IsNullOrWhiteSpace(accountName)) { throw new ArgumentException($"'{nameof(accountName)}' cannot be null or whitespace", nameof(accountName)); } if (string.IsNullOrWhiteSpace(accountKey)) { throw new ArgumentException($"'{nameof(accountKey)}' cannot be null or whitespace", nameof(accountKey)); } this.connectionString = connectionString; this.containerName = containerName; this.accountName = accountName; this.accountKey = accountKey; var client = new Blobs.BlobServiceClient(this.connectionString); this.blobContainerClient = client.GetBlobContainerClient(this.containerName); }
public AzureBlobService(AzureBlobServiceOptions options, ILogger <AzureBlobService> logger) { client = new BlobServiceClient(options.ConnectionString, options.BlobClientOptions); foreach (var m in options.mappings) { mappings.Add(m); } mappings.Sort((a, b) => b.UrlPrefix.Length.CompareTo(a.UrlPrefix.Length)); }
/// <inheritdoc /> public async Task <ScannerContainer[]> ListAllContainers() { var uri = new Uri($"{this.config.AzureBlob.BasePath}/?{this.config.AzureBlob.Sas}"); var client = new Azure.Storage.Blobs.BlobServiceClient(uri); var containers = new List <ScannerContainer>(); await foreach (var container in client.GetBlobContainersAsync()) { // skip "system" containers if (!container.Name.StartsWith("0-")) { containers.Add(new ScannerContainer(container.Name)); } } return(containers.ToArray()); }