An Azure service that stores unstructured data in the cloud as blobs.
Hello @Grace Dong,
Thanks for reaching out to Microsoft Q&A.
I understand that you are facing the issue with Document Translation service isn’t able to enumerate or read your blobs with the SAS token you generated.
As we discussed, you are using the user delegation type and experiencing an error in the portal. If you have trouble with the portal, you can use the code below to generate a SAS token and access content from Azure Blob Storage:
using Azure.Identity;
using Azure.Storage.Blobs;
using Azure.Storage.Sas;
using System;
class Program
{
public static void Main(string[] args)
{
var containerName = "your container name";
var storageAccountName = "your storage account";
var blobName = "scenery.jpg";
var url = $"https://{storageAccountName}.blob.core.windows.net";
// Initialize BlobServiceClient using DefaultAzureCredential
var blobServiceClient = new BlobServiceClient(new Uri(url), new DefaultAzureCredential());
BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient(containerName);
// Get User Delegation Key
var userDelegationKey = blobServiceClient.GetUserDelegationKey(DateTimeOffset.UtcNow, DateTimeOffset.UtcNow.AddDays(1));
var sasBuilder = new BlobSasBuilder()
{
BlobContainerName = containerName,
BlobName = blobName,
Resource = "b",
StartsOn = DateTimeOffset.UtcNow,
ExpiresOn = DateTimeOffset.UtcNow.AddDays(1),
};
sasBuilder.SetPermissions(BlobSasPermissions.Read | BlobSasPermissions.Write);
// Construct the Blob URI with SAS token
var blobUriBuilder = new BlobUriBuilder(containerClient.Uri)
{
BlobName = blobName,
Sas = sasBuilder.ToSasQueryParameters(userDelegationKey, blobServiceClient.AccountName)
};
var blobUriWithSas = blobUriBuilder.ToUri();
Console.WriteLine(blobUriWithSas);
}
}
Using the code provided above will create a user delegation token, giving you the necessary permission to access the storage account.
Reference Document:
https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-user-delegation-sas-create-dotnet?tabs=packages-dotnetcli%2Ccontainer
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".