Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I create a SAS url for Azure File storage (i.e. not Blobs)

Using windows azure blob storage and providing access via a url with a Shared Access Signature is all normal and great. Can I do the same using files stored using the newer Azure File Storage?

The Get Blob REST api says you can use a Shared Access Signature, but the Get File REST API docs don't. So I'm guessing not.

If it's not possible, what's the suggested approach to give temporary access to someone? Create a copy as a blob and use SAS for that, or just don't use File Storage for this scenario?

like image 873
Rory Avatar asked Dec 01 '14 14:12

Rory


2 Answers

The latest WindowsAzure.Storage Version 5.0.0 has API to create SAS for Azure File Share.

Example (taken from Tool or usage example to generate and view SAS (Shared Access Signatures) of both Azure Block Blob and Azure File Share):

static void FileShareSas(){
    var account = new CloudStorageAccount(new StorageCredentials(accountName, accountKey), true);
    var fileClient = account.CreateCloudFileClient();
    var share = fileClient.GetShareReference("share");
    var sasToken = share.GetSharedAccessSignature(new Microsoft.WindowsAzure.Storage.File.SharedAccessFilePolicy(){
            Permissions = Microsoft.WindowsAzure.Storage.File.SharedAccessFilePermissions.List,
            SharedAccessExpiryTime = new DateTimeOffset(DateTime.UtcNow.AddDays(1))
        });
}

Feel free to check out this free tool as well: EverDir.com

like image 114
CarloZ Avatar answered Oct 14 '22 21:10

CarloZ


Currently it is not possible to create a Shared Access Signature for Azure File Service.

If it's not possible, what's the suggested approach to give temporary access to someone? Create a copy as a blob and use SAS for that, or just don't use File Storage for this scenario?

I would say, currently this is the best approach to do so. Other option would be to proxy your file service storage with your application.

like image 34
Gaurav Mantri Avatar answered Oct 14 '22 20:10

Gaurav Mantri