How can I generate a licensed download link in azure storage blob

I can get a link by those code, and it could download a file successfully.

BlobContainerSasPermission blobContainerSasPermission = new BlobContainerSasPermission()
BlobServiceSasSignatureValues builder = new BlobServiceSasSignatureValues(, blobContainerSasPermission)
BlobClient client = new BlobClientBuilder()
                .connectionString("connection string")
String blobContainerName = "test";
return String.format("",client.getAccountName(), blobContainerName, client.generateSas(builder));

but everyone could download the file by this link, I want the file could be downloaded by the one who is authorized. Is there any code or azure’s setting(such as AD?) could implement this? Thanks


I find a doc,and there gives a reason. Note: This method call is only valid when using TokenCredential in this object’s HttpPipeline. but there is only BasicAuthenticationCredential which implements TokenCredential in my imported package. This is my mvn.


And I tried this

String userName = "userName";
String password = "password";
BasicAuthenticationCredential basicAuthenticationCredential = new BasicAuthenticationCredential(userName,password);
BlobServiceClient blobServiceClient = new BlobServiceClientBuilder().endpoint(endpoint).credential(basicAuthenticationCredential).buildClient();

then I got this Status code 401, (InvalidAuthenticationInfo)

Gods, help me!


It looks like there is no way to implement this.

This is the answer.

Source: stackoverflow