Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Make generating blob URL with SAS easier #499

yavorg opened this Issue Nov 28, 2012 · 3 comments


None yet
5 participants

yavorg commented Nov 28, 2012

Dev: 5
Test: 3

Currently getting the blob URL with the shared access signature (SAS) is fairly tricky.

function formatDate(date){
        var raw = date.toJSON();
        return raw.substr(0, raw.lastIndexOf('.'))+'Z';

    var path = item.Container+"/"+ item.FileName+ item.Extension;

    item.SAS ='https://'+ account +'.blob.core.windows.net/'+ path +'?'+
            new azure.SharedAccessSignature(account, key).generateSignedQueryString(
                        Permissions: azure.Constants.BlobConstants.SharedAccessPermissions.WRITE,
                        Expiry: formatDate(newDate(newDate().getTime()+5*60*1000))// 5 minutes from now

Ideally, we would like to be able to do something more like this

var blobService = azure.createBlobService();
var signature = blobService.generateSharedSignature({your options here})
var url = blobService.getBlobUrl(container, blob, signature);

This is important for Mobile Services scenarios where we want to allow a client to upload a blob without giving the client the storage account key. This way we can safely store the storage account key on the backend and only send the blob URL + SAS back to the client to do the upload.


glennblock commented Dec 3, 2012

Looks like a great idea. We should look at whether we can supply overridable defaults for the options to improve the getting started experience.

@ghost ghost assigned andrerod Dec 23, 2012

@ghost ghost assigned xuezhai Jan 30, 2013

andrerod pushed a commit that referenced this issue Jan 30, 2013

Merge pull request #564 from andrerod/dev
#499: Make generating blob URL with SAS easier

markcowl commented Feb 5, 2013

@xuezhai can you close this bug?


xuezhai commented Feb 7, 2013

add the test and executed the variation for the seconds(minutues)fromNow. code checkin progress

@xuezhai xuezhai closed this Feb 7, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment