生成和查看Azure Block Blob和Azure File Share的SAS(共享访问签名)的工具或用法示例 [英] Tool or usage example to generate and view SAS (Shared Access Signatures) of both Azure Block Blob and Azure File Share

查看:448
本文介绍了生成和查看Azure Block Blob和Azure File Share的SAS(共享访问签名)的工具或用法示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个工具或用法示例,以生成和查看Azure Block Blob和Azure File Share的SAS(共享访问签名).有很多关于块Blob和容器的示例,但有关Azure File Share SAS的示例或工具呢?

I am looking for a tool or usage example to generate and view SAS (Shared Access Signatures) of both Azure Block Blob and Azure File Share. There are lots of examples for Block Blob and Containers but what about Azure File Share SAS examples or tools.

推荐答案

File Service Share上创建Shared Access Signature的能力.为此,必须使用Storage Client Library 5.0.0.

Ability to create Shared Access Signature on a File Service Share is announced in the latest version of REST API. You must use Storage Client Library 5.0.0 for that purpose.

首先,从 Nuget :

Install-Package WindowsAzure.Storage -Version 5.0.0

Install-Package WindowsAzure.Storage -Version 5.0.0

然后,在文件服务共享上创建SAS的过程与在Blob容器上创建SAS的过程非常相似.请参见下面的示例代码:

Then the process of creating a SAS on a File Service Share is very much similar to creating a SAS on a blob container. Please see 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))
            });
    }

在上面的代码中,我们正在创建具有List权限的SAS,该SAS权限将从当前日期/时间(以UTC表示)开始一天失效.

In the above code, we're creating a SAS with List permission that will expire one day from current date/time (in UTC).

如果您正在寻找一种这样做的工具,我是否建议您看一下 Cloud Portam (披露:我正在构建此工具).最近,我们发布了以下功能:在共享上管理SAS .

Also if you're looking for a tool to do so, may I suggest you take a look at Cloud Portam (Disclosure: I am building this tool). Recently we released the functionality to manage SAS on a Share.

这篇关于生成和查看Azure Block Blob和Azure File Share的SAS(共享访问签名)的工具或用法示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆