An example of a tool or use for generating and viewing SAS (shared signatures) of both Azure Block Blob and Azure File Share

I am looking for a tool or usage example for creating and viewing SAS (shared signatures) of both Azure Block Blob and Azure File Share. There are many examples for Block Blob and Containers, but what about examples or tools from ASUS File Share SAS.

+2
source share
1 answer

The ability to create a Shared Access Signature in File Service Share announced in the latest version of the REST API. You must use Storage Client Library 5.0.0 for this purpose.

First install this library from Nuget :

WindowsAzure.Storage -Version 5.0.0 Installation Package

Then the process of creating SAS in the file service sharing is very similar to creating SAS in the blob container. See the sample code below:

  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)) }); } 

In the above code, we create SAS with List permission, which expires one day from the current date / time (in UTC format).

Also, if you are looking for a tool for this, I can suggest you take a look at Cloud Portam (Disclosure: I am creating this tool). We recently released SAS management functionality in Share .

+5
source

Source: https://habr.com/ru/post/1208048/


All Articles