I am trying to list out the files in azure data lake Gen 2 container using azure sdk for java API through network proxy, but getting connection timed out errors every time. Followed the sample code from azure website itself.
Sample Code Link:: https://learn.microsoft.com/en-us/azure/storage/blobs/data-lake-storage-directory-file-acl-java
Code
public void connectToAzureDataLake() {
String endpoint = "endPoint_URL";
ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder()
.clientId("clientId")
.clientSecret("clientSecret")
.tenantId("tenantId")
.build();
int proxyPort = 1111;
HttpClient httpClient = new NettyAsyncHttpClientBuilder()
.proxy(new ProxyOptions(ProxyOptions.Type.HTTP,
new InetSocketAddress("proxyURL", proxyPort))
.setCredentials("proxyUsername", "proxyPassword")).build();
DataLakeServiceClientBuilder builder = new DataLakeServiceClientBuilder();
DataLakeServiceClient dataLakeServiceClient = builder.credential(clientSecretCredential)
.endpoint(endpoint).httpClient(httpClient).buildClient();
DataLakeFileSystemClient dataLakeFileSystemClient = new DataLakeFileSystemClientBuilder()
.endpoint(endpoint + "/file_system_name")
.credential(clientSecretCredential)
.buildClient();
listFilesInDirectory(dataLakeFileSystemClient);
}
private void listFilesInDirectory(DataLakeFileSystemClient fileSystemClient) {
ListPathsOptions options = new ListPathsOptions();
options.setPath("folder_to_list_contents");
PagedIterable<PathItem> pagedIterable =
fileSystemClient.listPaths(options, null);
java.util.Iterator<PathItem> iterator = pagedIterable.iterator();
PathItem item = iterator.next();
while (item != null) {
System.out.println(item.getName());
if (!iterator.hasNext()) {
break;
}
item = iterator.next();
}
}
Even tried providing the proxy details through system.properties and -D options as well, but not succeeded.
-D options given:
-Dhttp.proxyHost
-Dhttp.proxyPort
-Dhttp.proxyUser
-Dhttp.proxyPassword
-Dhttps.proxyHost
-Dhttps.proxyPort
-Dhttps.proxyUser
-Dhttps.proxyPassword
Any pointers to resolve the issue would be highly appreciated. Thanks in advance.