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.
- Then create a confidential Client Application
- Acquire a Token: Use the
acquireToken
method to get a token for accessing Azure resources. - 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:
- Create a service SAS for a container or blob with Java
- Client credentials in MSAL Java
- Create a user delegation SAS for a container or blob with Java
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.