Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
Hi M, RAKESH
Generate SAS token for specific folders No, it is not possible to generate a
SAStoken for a specific folder if your storage account is a general-purpose v2 account with a flat namespace. Blob containers in such accounts do not have real folders and do not support folder-level security.
To generate a SAS token for a specific folder, you need to upgrade your storage account to an Azure Data Lake Gen2 storage account using this MS-Document.
Note: Before Upgrading read and review the feature support.
Once you complete the process, you will see a success message similar to the one shown in the image.
Now, you will be able to generate a SAS token for a specific directory through the portal UI.

If you need to generate a SAS token for a specific folder using PowerShell, you can use the script below for an Azure Data Lake Gen2 storage account.
Script:
$storageAccountName = "xxxx"
$containerName = "xxxx"
$folderPath = "A/B/C" # Path to the folder in ADLS Gen2
$encodedFolderPath = [System.Web.HttpUtility]::UrlEncode($folderPath)
$expiryTime = (Get-Date).AddYears(1)
$permissions = "racwl"
$storageAccountKey = "xxxxxxx"
# Create a storage context
$context = New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey
# Generate the SAS token for the folder in Data Lake Gen2
$sasToken = New-AzDataLakeGen2SasToken `
-Context $context `
-FileSystem $containerName `
-Path $folderPath `
-Permission $permissions `
-ExpiryTime $expiryTime
# Construct the full SAS URL
$folderUrl = "https://$storageAccountName.dfs.core.windows.net/$containerName/$encodedFolderPath"
$completeSasUrl = "{0}?{1}" -f $folderUrl, $sasToken
# Output the complete SAS URL
Write-Output "Generated SAS URL:"
Write-Output $completeSasUrl
Output:
Generated SAS URL:
https://venkat9012.dfs.core.windows.net/test/demo?sv=2023-08-03&se=2026-03-27T13%3A55%3A12Z&sr=d&sp=racwl&sdd=1&sig=redacted
If you need to use only a flat namespace storage account, you can try the solution recommended by Hari Babu Vattepally.
Reference:
New-AzDataLakeGen2SasToken (Az.Storage) | Microsoft Learn
Hope this answer helps! please let us know if you have any further queries. I’m happy to assist you further.
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.