/// <inheritdoc /> public async Task <AuditBlob[]> GetUnprocessedAudits(ScannerContainer container) { var uri = new Uri($"{this.config.AzureBlob.BasePath}/{container.Name}?{this.config.AzureBlob.Sas}"); var client = new Azure.Storage.Blobs.BlobContainerClient(uri); var blobs = new List <AuditBlob>(); await foreach (var blob in client.GetBlobsAsync(BlobTraits.Metadata)) { // skip all not metadata file. if (!blob.Name.EndsWith("meta")) { continue; } if (blob.Metadata == null || !blob.Metadata.ContainsKey(ProcessedMetadataKey)) { blobs.Add(new AuditBlob { Name = blob.Name, ParentContainer = container, }); } } return(blobs.ToArray()); }
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); }
/// <summary> /// The method returns all audit files in the container. /// </summary> /// <param name="container">The container with audits.</param> /// <returns>Array of Audit blobs.</returns> public async Task MarkAllAuditsAsUnprocessed(ScannerContainer container) { var uri = new Uri($"{this.config.AzureBlob.BasePath}/{container.Name}?{this.config.AzureBlob.Sas}"); var client = new Azure.Storage.Blobs.BlobContainerClient(uri); await foreach (var blob in client.GetBlobsAsync()) { // skip all not metadata file. if (!blob.Name.EndsWith("meta")) { continue; } await client.GetBlobClient(blob.Name).SetMetadataAsync(new Dictionary <string, string>()); } }
private void button1_Click(object sender, EventArgs e) { string file = textBox3.Text; string downloadpath = textBox4.Text; downloadpath = downloadpath.Replace(@"\", @"\\"); lblmessage.Text = ""; try { Azure.Storage.Blobs.BlobContainerClient container = new Azure.Storage.Blobs.BlobContainerClient(textBox1.Text, textBox2.Text); var BlobClient = container.GetBlobClient(textBox3.Text); BlobClient.DownloadTo(downloadpath + "\\" + file); lblmessage.Text = "Downloaded file to " + textBox4.Text + @"\" + file + " Sucessfully"; } catch (Exception ex) { lblmessage.Text = ex.Message.ToString(); } }