📜  为 azure blob 生成 sas 令牌 - 无论代码示例

📅  最后修改于: 2022-03-11 14:55:54.207000             🧑  作者: Mango

代码示例1
Azure.Storage.Sas.BlobSasBuilder blobSasBuilder = new Azure.Storage.Sas.BlobSasBuilder()
        {
            BlobContainerName = "demo-copy",
            BlobName = "test.txt",
            ExpiresOn = DateTime.UtcNow.AddMinutes(5),//Let SAS token expire after 5 minutes.
        };
        blobSasBuilder.SetPermissions(Azure.Storage.Sas.BlobSasPermissions.Read);//User will only be able to read the blob and it's properties
        var sasToken = blobSasBuilder.ToSasQueryParameters(new StorageSharedKeyCredential(accountName, accountKey)).ToString();
        var sasUrl = blobClient.Uri.AbsoluteUri + "?" + sasToken;