moondaisy moondaisy - 1 year ago 166
Java Question

Azure java: SAS identifier cannot be found for specified signed identifier

I'm using the SDK for java to crear a SAS to access a blob.
This is the code:

SharedAccessBlobPolicy policy = new SharedAccessBlobPolicy();
Calendar date = Calendar.getInstance();
Date expire = new Date(date.getTimeInMillis() + (expirationMinutes * 60000));
Date start = new Date(date.getTimeInMillis());
return blob.getUri().toString()+"?"+blob.generateSharedAccessSignature(policy, externalFileName);

But when I try to use the url to access the blob I get this error:

Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:f1f169d2-0001-003f-115a-3be1d6000000 Time:2016-11-10T13:57:14.6192554Z
SAS identifier cannot be found for specified signed identifier

I'm doing the same thing in NET for the same blob an the resulting url (which works) is different that the one I get here:

Doesn't work (java):


Works (NET):


How could I fix this?

Answer Source

Just looking at the SAS token, you are specifying a policy with the filename. That's probably not what you wanted to do, and is not in the .NET SAS token.

The problem is here I guess:

blob.generateSharedAccessSignature(policy, externalFileName);

The second parameter is probably the policy name, if the API is similar to .NET.

Try this instead:

blob.generateSharedAccessSignature(policy, null);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download