azure-storage-blob-java – Coding skill for AI agents
Build blob storage applications using the Azure Storage Blob SDK for Java.
Install the azure-storage-blob-java skill with one command
Pick the tool you use, copy the command and paste it in your terminal. The skill lands in that tool's skills folder and is ready in your next session.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-storage-blob-java-d0d1f.tgz | tar xz -C ~/.claude/skills
Call it in Claude Code: /azure-storage-blob-java – then describe the task you want done.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-storage-blob-java-d0d1f.tgz | tar xz -C ~/.codex/skills
Call it in Codex: $azure-storage-blob-java – then describe the task you want done.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-storage-blob-java-d0d1f.tgz | tar xz -C ~/.hermes/skills
Call it in Hermes Agent: /azure-storage-blob-java – then describe the task you want done.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-storage-blob-java-d0d1f.tgz | tar xz -C ~/.deepcode/skills
Call it in DeepSeek: /azure-storage-blob-java – then describe the task you want done.
SKILL.md content
Azure Storage Blob SDK for Java
Build blob storage applications using the Azure Storage Blob SDK for Java.
Installation
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-blob</artifactId>
<version>12.33.0</version>
</dependency>Client Creation
BlobServiceClient
import com.azure.storage.blob.BlobServiceClient;
import com.azure.storage.blob.BlobServiceClientBuilder;
// With SAS token
BlobServiceClient serviceClient = new BlobServiceClientBuilder()
.endpoint("<storage-account-url>")
.sasToken("<sas-token>")
.buildClient();
// With connection string
BlobServiceClient serviceClient = new BlobServiceClientBuilder()
.connectionString("<connection-string>")
.buildClient();With DefaultAzureCredential
import com.azure.identity.DefaultAzureCredentialBuilder;
BlobServiceClient serviceClient = new BlobServiceClientBuilder()
.endpoint("<storage-account-url>")
.credential(new DefaultAzureCredentialBuilder().build())
.buildClient();BlobContainerClient
import com.azure.storage.blob.BlobContainerClient;
// From service client
BlobContainerClient containerClient = serviceClient.getBlobContainerClient("mycontainer");
// Direct construction
BlobContainerClient containerClient = new BlobContainerClientBuilder()
.connectionString("<connection-string>")
.containerName("mycontainer")
.buildClient();BlobClient
import com.azure.storage.blob.BlobClient;
// From container client
BlobClient blobClient = containerClient.getBlobClient("myblob.txt");
// With directory structure
BlobClient blobClient = containerClient.getBlobClient("folder/subfolder/myblob.txt");
// Direct construction
BlobClient blobClient = new BlobClientBuilder()
.connectionString("<connection-string>")
.containerName("mycontainer")
.blobName("myblob.txt")
.buildClient();Storage and bearer-token scope
Verify the account/container/key and current SDK signatures before adapting these independent snippets. Overwrite, snapshot deletion, metadata/header replacement and cross-account copies require exact-target authority and concurrency conditions where needed. Bound in-memory downloads; prefer streaming for large blobs. A SAS is a bearer credential: authorize the object and caller, minimize permission/expiry, use HTTPS, avoid logs and prefer user-delegation SAS where applicable. generateSas needs the appropriate signing credential; DefaultAzureCredential alone does not make that method account-key signing. Check copy completion status and failures rather than assuming waiting guarantees success.
Core Patterns
Create Container
// Create container
serviceClient.createBlobContainer("mycontainer");
// Create if not exists
BlobContainerClient container = serviceClient.createBlobContainerIfNotExists("mycontainer");
// From container client
containerClient.create();
containerClient.createIfNotExists();Upload Data
import com.azure.core.util.BinaryData;
// Upload string
String data = "Hello, Azure Blob Storage!";
blobClient.upload(BinaryData.fromString(data));
// Upload with overwrite
blobClient.upload(BinaryData.fromString(data), true);Upload from File
blobClient.uploadFromFile("local-file.txt");
// With overwrite
blobClient.uploadFromFile("local-file.txt", true);Upload from Stream
import com.azure.storage.blob.specialized.BlockBlobClient;
BlockBlobClient blockBlobClient = blobClient.getBlockBlobClient();
byte[] utf8 = data.getBytes(java.nio.charset.StandardCharsets.UTF_8);
try (ByteArrayInputStream dataStream = new ByteArrayInputStream(utf8)) {
blockBlobClient.upload(dataStream, utf8.length);
}Upload with Options
import com.azure.storage.blob.models.BlobHttpHeaders;
import com.azure.storage.blob.options.BlobParallelUploadOptions;
BlobHttpHeaders headers = new BlobHttpHeaders()
.setContentType("text/plain")
.setCacheControl("max-age=3600");
Map<String, String> metadata = Map.of("author", "john", "version", "1.0");
try (InputStream stream = new FileInputStream("large-file.bin")) {
BlobParallelUploadOptions options = new BlobParallelUploadOptions(stream)
.setHeaders(headers)
.setMetadata(metadata);
blobClient.uploadWithResponse(options, null, Context.NONE);
}Upload if Not Exists
import com.azure.storage.blob.models.BlobRequestConditions;
BlobParallelUploadOptions options = new BlobParallelUploadOptions(inputStream, length)
.setRequestConditions(new BlobRequestConditions().setIfNoneMatch("*"));
blobClient.uploadWithResponse(options, null, Context.NONE);Download Data
// Download to BinaryData
BinaryData content = blobClient.downloadContent();
String text = content.toString();
// Download to file
blobClient.downloadToFile("downloaded-file.txt");Download to Stream
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
blobClient.downloadStream(outputStream);
byte[] data = outputStream.toByteArray();
}Download with InputStream
import com.azure.storage.blob.specialized.BlobInputStream;
try (BlobInputStream blobIS = blobClient.openInputStream()) {
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = blobIS.read(buffer)) != -1) {
// Process buffer
}
}Upload via OutputStream
import com.azure.storage.blob.specialized.BlobOutputStream;
try (BlobOutputStream blobOS = blobClient.getBlockBlobClient().getBlobOutputStream()) {
blobOS.write("Data to upload".getBytes());
}List Blobs
import com.azure.storage.blob.models.BlobItem;
// List all blobs
for (BlobItem blobItem : containerClient.listBlobs()) {
System.out.println("Blob: " + blobItem.getName());
}
// List with prefix (virtual directory)
import com.azure.storage.blob.models.ListBlobsOptions;
ListBlobsOptions options = new ListBlobsOptions().setPrefix("folder/");
for (BlobItem blobItem : containerClient.listBlobs(options, null)) {
System.out.println("Blob: " + blobItem.getName());
}List Blobs by Hierarchy
import com.azure.storage.blob.models.BlobListDetails;
String delimiter = "/";
ListBlobsOptions options = new ListBlobsOptions()
.setPrefix("data/")
.setDetails(new BlobListDetails().setRetrieveMetadata(true));
for (BlobItem item : containerClient.listBlobsByHierarchy(delimiter, options, null)) {
if (item.isPrefix()) {
System.out.println("Directory: " + item.getName());
} else {
System.out.println("Blob: " + item.getName());
}
}Delete Blob
blobClient.delete();
// Delete if exists
blobClient.deleteIfExists();
// Delete with snapshots
import com.azure.storage.blob.models.DeleteSnapshotsOptionType;
blobClient.deleteWithResponse(DeleteSnapshotsOptionType.INCLUDE, null, null, Context.NONE);Copy Blob
import com.azure.storage.blob.models.BlobCopyInfo;
import com.azure.core.util.polling.SyncPoller;
// Async copy (for large blobs or cross-account)
SyncPoller<BlobCopyInfo, Void> poller = blobClient.beginCopy("<source-blob-url>", Duration.ofSeconds(1));
poller.waitForCompletion();
// Sync copy from URL (for same account)
blobClient.copyFromUrl("<source-blob-url>");Generate SAS Token
import com.azure.storage.blob.sas.*;
import java.time.OffsetDateTime;
// Blob-level SAS
BlobSasPermission permissions = new BlobSasPermission().setReadPermission(true);
OffsetDateTime expiry = OffsetDateTime.now().plusDays(1);
BlobServiceSasSignatureValues sasValues = new BlobServiceSasSignatureValues(expiry, permissions);
String sasToken = blobClient.generateSas(sasValues);
// Container-level SAS
BlobContainerSasPermission containerPermissions = new BlobContainerSasPermission()
.setReadPermission(true)
.setListPermission(true);
BlobServiceSasSignatureValues containerSasValues = new BlobServiceSasSignatureValues(expiry, containerPermissions);
String containerSas = containerClient.generateSas(containerSasValues);Blob Properties and Metadata
import com.azure.storage.blob.models.BlobProperties;
// Get properties
BlobProperties properties = blobClient.getProperties();
System.out.println("Size: " + properties.getBlobSize());
System.out.println("Content-Type: " + properties.getContentType());
System.out.println("Last Modified: " + properties.getLastModified());
// Set metadata
Map<String, String> metadata = Map.of("key1", "value1", "key2", "value2");
blobClient.setMetadata(metadata);
// Set HTTP headers
BlobHttpHeaders headers = new BlobHttpHeaders()
.setContentType("application/json")
.setCacheControl("max-age=86400");
blobClient.setHttpHeaders(headers);Lease Blob
import com.azure.storage.blob.specialized.BlobLeaseClient;
import com.azure.storage.blob.specialized.BlobLeaseClientBuilder;… (full content is in the download package)
Related skills
- openapi-spec-generation – Generate and maintain OpenAPI 3.1 specifications from code, design-first specs, and…
- parallel-debugging – Debug complex issues using competing hypotheses with parallel investigation, evidence…
- hunt-source-leak – Hunt source code and build artifact leakage — JavaScript source maps (.js.map)…
- azure-storage-blob-rust – Azure Blob Storage SDK for Rust. Use for uploading, downloading, and managing blobs and…
- azure-storage-queue-rust – Azure Queue Storage library for Rust. Send, receive, and manage queue messages…
- site-architecture – When the user wants to plan, map, or restructure their website's page hierarchy…
- babysit-pr – Babysit a pull request through its bot review rounds: verify, fix, reply, resolve. Use…
- backend-architect – Expert backend architect specializing in scalable API design, microservices…