Share via

Azure Storage - Proxy Setting in Java Code

Charles De Saint André 1 Reputation point
2022-07-13T09:51:58.95+00:00

Hi evryone,

In a java service, I'm trying to upload a file in an azure storage directory; therefore I've written a code like this :

import com.azure.core.util.*;  

import com.azure.storage.file.share.*;  

import com.azure.storage.file.share.models.*;  


//Create connexion string  

String connectStr ="DefaultEndpointsProtocol=https;AccountName=" + accountName + ";AccountKey=" + accountKey + ";EndpointSuffix=" + endpoint;  

         
//ShareDirectoryClient  

         
ShareDirectoryClient dirClient = new     ShareFileClientBuilder().connectionString(connectStr).shareName(shareName).resourcePath(directoryName).configuration(proxyOptions).buildDirectoryClient();  

         
// Create empty file  

dirClient.createFile(fileName, body.length());  

The HTTPS request must goes through a proxy server, so, I get this error :

"Could not run 'sendFileInDirectoryProxyTest' reactor.core.Exceptions$ReactiveException: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection timed out: no further information: "

I can't set/use a global setting. To set a proxy in the Java code, I've tried several things, like using the Configuration Class :

Configuration configuration = new Configuration();  

configuration.put("java.net.useSystemProxies", "true");  

configuration.put("https.proxyHost", "xxxxxxxxx");  

configuration.put("https.proxyPort", "xxxx");  

         
ShareDirectoryClient dirClient = new     ShareFileClientBuilder().connectionString(connectStr).shareName(shareName).resourcePath(directoryName).configuration(configuration).buildDirectoryClient();  

         

But it did not solve the issue. I'm sure it is pretty simple, any help would be appreciated.

Thanks. Charles de Saint Andre.

Azure Storage
Azure Storage

Globally unique resources that provide access to data management services and serve as the parent namespace for the services.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.