0
votes

How to create SAS url for azure blob storage using java How to generate azure blob storage SAS url using java?

do we have any api where i can expire any existing sas url?

Requirement: Generate any sas url with expiry time as 7 days and i want some api where i can reset this sas url at any point of time within expiry time limit.

but looks like we don't have this i guess and every time it will create new sas url but we can expire any existing sas url at any point of time.

1
BlobServiceSasSignatureValues.setExpiryTime(OffsetDateTime expiryTime) Method is used to set the time after which the SAS will no longer work. It may help.Pamela Peng
@Pamela Peng my question is if i already has a sas url with expiry day as 7 days. and i want to expire it before 7 days can it be possbile?Mohit Singh
If I don't misunderstand, you would like to expire the SAS token much earlier than expected. It seems impossible. Because you can not edit an existing SAS token once generated, and the SAS token will not change even though you generate a new one.Pamela Peng

1 Answers

0
votes

You can create an access policy on the container with set start and end date. Then create a SAS token on the container or an individual blob using that policy. Once the policy is deleted it will also invalidate all SAS tokens that were generated with it.

public BlobServiceSasSignatureValues(String identifier)
//Where identifier is the name of the access policy

It's limited to 5 access policies on a table, but if you are a bit flexible on the expiration date you could make one each week, so every blob would be available for at least a week and up to two at most. It also implies that once you remove the policy all url's for that week no longer work.

I don't think there's any other way you are able to invalidate the generated url's apart from generating new accesss keys.