Progress (well, got it compiling at least)!
Initially, I’d downloaded azure-storage-blob-12.14.2.jar
. Later, I found its webpage lists four additional JAR package as dependencies. I downloaded these into the /code/jars folder and reloaded the package:
azure-core-1.22.0.jar
azure-core-http-netty-1.11.2.jar
azure-storage-common-12.14.1.jar
azure-storage-internal-avro-12.1.2.jar
…then kept fixing compile errors until I got this code to compile:
import com.azure.storage.blob.models.*;
import com.azure.storage.*;
import com.azure.storage.common.*;
import com.azure.core.exception.*;
...
/* Create a new BlobServiceClient with a Shared Key */
BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
.endpoint("https://<storage-account-name>.blob.core.windows.net")
.credential (new StorageSharedKeyCredential("<accountName>", "<accountKey>") )
.buildClient();
BlobContainerClient containerClient =null;
/* Create a new container client */
try {
containerClient = blobServiceClient.createBlobContainer("<container-name>");
} catch (BlobStorageException ex) {
// The container may already exist, so don't throw an error
if (!ex.getErrorCode().equals(BlobErrorCode.CONTAINER_ALREADY_EXISTS)) {
throw ex;
}
}
/* Upload the file to the container */
BlobClient blobClient = containerClient.getBlobClient("file.csv");
blobClient.uploadFromFile("file.csv");
Next week I plan to progress further. One essential change I need is to make blobClient
accept a stream as input.