generate SAS tokens from serviceprincipal credentials

SHYAMALA GOWRI 90 Reputation points
2025-01-08T12:00:29.36+00:00

I am working on to create java client that generates sas tokens for the given service principal credentials. I am taking a reference from https://github.com/AzureAD/microsoft-authentication-library-for-java/blob/dev/msal4j-sdk/src/samples/confidential-client/ClientCredentialGrant.java

Where we will need to pass the following prop and acquire the sas tokens ?

Azure Data Lake Storage
Azure Data Lake Storage
An Azure service that provides an enterprise-wide hyper-scale repository for big data analytic workloads and is integrated with Azure Blob Storage.
1,531 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
23,011 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Hari Babu Vattepally 1,475 Reputation points Microsoft Vendor
    2025-01-15T10:28:29.9033333+00:00

    Hi @SHYAMALA GOWRI,

    Welcome to Microsoft Q&A Forum. Thanks for posting your query!

    Firstly, Apologies for delay in response. Here to generate SAS tokens using service principal credentials in your Java client, you can use Microsoft Authentication Library (MSAL) for Java in which you have to create a confidential client application using your service principal's client ID and client secret. So here we have a general approach to acquire a token and generate a SAS token:1. We need to setup MSAL, by adding MSAL4J to your project dependencies.

    1. Then create a confidential Client Application
    2. Acquire a Token: Use the acquireToken method to get a token for accessing Azure resources.
    3. Generate SAS Token: Once you have the token, you can use it to create a service SAS for your Azure Blob Storage resources.

    Please make sure to replace CLIENT_SECRET, CLIENT_ID, and AUTHORITY with your actual service principal credentials.

    For more additional information, please refer the below:

    I hope this helps in resolving the query.

    Please feel free to contact us for any further assistance. We will be glad to assist you closely.

    Please do consider to “up-vote” wherever the information provided helps you, this can be beneficial to other community members.


Your answer

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