I need to upload some *.csv files to the azure blob storage from the.sh file which is located in azure linux webapp. is it possible to do that or how I can do it. Can someone give a sample code if it is possible.
Of curse, you can run the shell script in the Java code with Runtime.getRunTime().exec , the example code here:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class RunningSS {
public static void main(String[] args) {
Process p;
try {
String[] cmd = { "sh", "/home/adb/Documents/test.sh"};
p = Runtime.getRuntime().exec(cmd);
p.waitFor();
BufferedReader reader=new BufferedReader(new InputStreamReader(
p.getInputStream()));
String line;
while((line = reader.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
To upload the file in the shell script, you can use the Azure CLI command or azcopy . For example, if you want to upload the files to the Azure Storage File, then the CLI command is az storage file upload
, but if you use CLI, you need to install it first. See Install the Azure CLI .
I do not recommend the REST API, it's too complex. If you do not mind, you can take a try.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.