public void FineGrainedBatching() { string connectionString = ConnectionString; string containerName = Randomize("sample-container"); #region Snippet:SampleSnippetsBatch_FineGrainedBatching // Get a connection string to our Azure Storage account. //@@ string connectionString = "<connection_string>"; //@@ string containerName = "sample-container"; // Get a reference to a container named "sample-container" and then create it BlobServiceClient service = new BlobServiceClient(connectionString); BlobContainerClient container = service.GetBlobContainerClient(containerName); container.Create(); // Create three blobs named "foo", "bar", and "baz" BlobClient foo = container.GetBlobClient("foo"); BlobClient bar = container.GetBlobClient("bar"); BlobClient baz = container.GetBlobClient("baz"); foo.Upload(new MemoryStream(Encoding.UTF8.GetBytes("Foo!"))); foo.CreateSnapshot(); bar.Upload(new MemoryStream(Encoding.UTF8.GetBytes("Bar!"))); bar.CreateSnapshot(); baz.Upload(new MemoryStream(Encoding.UTF8.GetBytes("Baz!"))); // Create a batch with three deletes BlobBatchClient batchClient = service.GetBlobBatchClient(); BlobBatch batch = batchClient.CreateBatch(); batch.DeleteBlob(foo.Uri, DeleteSnapshotsOption.IncludeSnapshots); batch.DeleteBlob(bar.Uri, DeleteSnapshotsOption.OnlySnapshots); batch.DeleteBlob(baz.Uri); // Submit the batch batchClient.SubmitBatch(batch); #endregion Pageable <BlobItem> blobs = container.GetBlobs(states: BlobStates.Snapshots); Assert.AreEqual(1, blobs.Count()); Assert.AreEqual("bar", blobs.FirstOrDefault().Name); // Clean up after the test when we're finished container.Delete(); }