Connecting to Azure storage account thru proxy server Microsoft Azure Storage SDK for Java tells me how to specify proxyHost and Port using OperationContext.
I still cannot figure out how to specify the proxyUser and proxyPassword attributes.
I get a StorageException encountered: The server encountered an unknown failure: when I try the following code:
Authenticator.setDefault(
new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(
authUser, authPassword.toCharArray());
}
}
);
System.setProperty("http.proxyHost", proxyHost);
System.setProperty("http.proxyPort", proxyPort);
System.setProperty("https.proxyHost", proxyHost);
System.setProperty("https.proxyPort", proxyPort);
System.setProperty("http.proxyUser", authUser);
System.setProperty("http.proxyPassword", authPassword);
System.setProperty("https.proxyUser", authUser);
System.setProperty("https.proxyPassword", authPassword);
try {
CloudStorageAccount account = CloudStorageAccount.parse(storageConnectionString);
CloudBlobClient serviceClient = account.createCloudBlobClient();
CloudBlobContainer container = serviceClient.getContainerReference(resourcePrefix);
container.createIfNotExists(null, op);
CloudBlockBlob blob = container.getBlockBlobReference(resourceName);
File sourceFile = new File(resourceName);
blob.upload(new FileInputStream(sourceFile), sourceFile.length());
}
catch (FileNotFoundException fileNotFoundException) {
System.out.print("FileNotFoundException encountered: ");
System.out.println(fileNotFoundException.getMessage());
System.exit(-1);
}
catch (StorageException storageException) {
System.out.print("StorageException encountered: ");
System.out.println(storageException.getMessage());
System.exit(-1);
}
catch (Exception e) {
System.out.print("Exception encountered: ");
System.out.println(e.getMessage());
System.exit(-1);
}