cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Export CSV to Azure Cloud Blob Storage

shaktimohanty
Explorer
1,601

I wish to export the Orders Data in a csv file to Azure Blob storage linked to the azure account in hybris. How can I push the file. We have been using it for hot folder import but now, we plan to export the file to a new container.

Accepted Solutions (0)

Answers (1)

Answers (1)

a_e_dubey
Active Participant
0 Likes

Hi ashiktmz You can use Azure Blob API and these API provide access to Blob Storage.

Just for reference see below code , this is sample code

public static final String storageConnectionString =
"DefaultEndpointsProtocol=https;" +
"AccountName=<account-name>;" +
"AccountKey=<account-key>";
// Parse the connection string and create a blob client to interact with Blob storage
storageAccount = CloudStorageAccount.parse(storageConnectionString);
blobClient = storageAccount.createCloudBlobClient();
container = blobClient.getContainerReference("quickstartcontainer");


// Create the container if it does not exist with public access.
System.out.println("Creating container: " + container.getName());
container.createIfNotExists(BlobContainerPublicAccessType.CONTAINER, new BlobRequestOptions(), new OperationContext());

//Creating a sample file
sourceFile = File.createTempFile("sampleFile", ".txt");
System.out.println("Creating a sample file at: " + sourceFile.toString());
Writer output = new BufferedWriter(new FileWriter(sourceFile));
output.write("Hello Azure!");
output.close();


//Getting a blob reference
CloudBlockBlob blob = container.getBlockBlobReference(sourceFile.getName());


//Creating blob and uploading file to it
System.out.println("Uploading the sample file ");
blob.uploadFromFile(sourceFile.getAbsolutePath());

I hope this will help. Else see microsoft docs for blob API.