'JAR activity is not working as expected in Azure Data Factory

I have a Java application which downloads a file from Azure Storage Account, encrypts this file and then uploads the encrypted file to another folder in the same Storage Account.

This is part of the code:

// Define the path to a local file.
        String filePath = "encrypted.txt";

        // Create or overwrite the blob with contents from a local file.
        //upload encrypted file
        CloudBlockBlob blobToUpload = container.getBlockBlobReference("test/output/encrypted.txt");
        File source = new File(filePath);
        blobToUpload.upload(new FileInputStream(source), source.length());

This application works perfectly if it's executed in my local machine (I'm using IntelliJ).

Encrypted file is correctly placed in folder "test/ouptut"

I need to execute this same process in Azure Data Factory by using JAR activity so I'm following the next steps:

1 - Generate the JAR file in IntelliJ

2 - Upload the JAR file to the Cluster in Azure Databricks

3 - Add and configure JAR activity in Azure Data Factory

JAR File configuration

Even when the JAR activity is executed with success, encrypted file was not uploaded. I did some tests and Java code is read but seems like key actions (download file, upload file) are not being executed correctly.

enter image description here

Any idea on why java code is not being executed correctly in the JAR Activity?

Thanks!



Solution 1:[1]

Some ways that we have for calling Jar or Executeable from the data factory are Batch Account, Functions, WebJobs.

For lightweight, serverless way to run your Java app, you can consider azure functions .You can try using java in Azure functions to achieve what you are trying to do with your jar code so that it would then be easy to invoke an Azure function from Azure Data Factory .You can check this document : Azure Functions Java developer guide

Or through Execute Jar File through Azure web jobs in Azure App Service | by Imran Shahid

Azure Data Factory Documentation - Azure Data Factory | Microsoft Docs

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 kavyasaraboju-MT