I used to be able to create a shared access signature on a Blob using the v11 Azure SDK API, like this:
(我曾经能够使用v11 Azure SDK API在Blob上创建共享访问签名,如下所示:)
var containerName = "mycontainer";
var blobName = "myblob";
CloudStorageAccount storageAccount
= CloudStorageAccount.Parse(<StorageConnectionString>);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference(containerName);
SharedAccessBlobPermissions permission = SharedAccessBlobPermissions.Read;
TimeSpan clockSkew = TimeSpan.FromMinutes(15d);
TimeSpan accessDuration = TimeSpan.FromMinutes(15d);
var blobSAS = new SharedAccessBlobPolicy
{
SharedAccessStartTime = DateTime.UtcNow.Subtract(clockSkew),
SharedAccessExpiryTime = DateTime.UtcNow.Add(accessDuration) + clockSkew,
Permissions = permissions
};
CloudBlockBlob blob = container.GetBlockBlobReference(blobName);
string sasBlobToken = blob.GetSharedAccessSignature(blobSAS);
...
I want to use the latest v12 .NET API which seems to replace CloudBlobClient
by BlobServiceClient
, CloudBlobContainer
by BlobContainerClient
and CloudBlockBlob
by BlobClient
.
(我想用最新的V12 .NET API,这似乎取代CloudBlobClient
由BlobServiceClient
, CloudBlobContainer
通过BlobContainerClient
和CloudBlockBlob
通过BlobClient
。)
However the method GetSharedAccessSignature
that is available on a CloudBlockBlob
instance is not available on a BlobClient
instance.
(然而该方法GetSharedAccessSignature
上可用的一个CloudBlockBlob
实例不可在BlobClient
实例。)
Question
(题)
How to get a shared access signature from a BlobClient
instance using the latest Azure SDK .NET API v12?
(如何使用最新的Azure SDK .NET API v12从BlobClient
实例获取共享访问签名?)
ask by Kzrystof translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…