'SAS token using Azure AD Service Principle for ADLS Gen2 at directory level in java

I have been trying to get a SAS token for ADLS Gen2 using java but haven't got any good example or document, Can anyone please provide an example or document to follow. (I am able to generate for blob storage at container level but not for ADLS Gen2 at directory level)



Solution 1:[1]

Have you considered the azure-storage-file-datalake library?

Since version 12.3.0 it supports Directory scoped SAS tokens, try DataLakeDirectoryClient#generateSas().

DataLakeDirectoryClient directoryClient = dataLakeServiceClient
    .getFileSystemClient("fileSystemName")
    .getDirectoryClient("path/to/directory");

var startTime = OffsetDateTime.now();
var permissions = new PathSasPermission().setReadPermission(true);
var values = new DataLakeServiceSasSignatureValues(startTime.plusDays(1),permissions)
    .setStartTime(startTime);

directoryClient.generateSas(values);

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 sschmeck