You can use the Azure.Storage.Blobs library instead of the Azure.Storage.Files.DataLake library
using Azure.Storage.Blobs;
using Azure.Storage.Blobs.Models;
using Azure.Storage.Sas;
using System;
// Set the connection string for the storage account
string connectionString = "<your connection string>";
// Set the container name and folder name
string containerName = "<your container name>";
string folderName = "<your folder name>";
// Set the access level (e.g. "r" for read, "rw" for read and write)
string accessLevel = "<your access level>";
// Set the group name
string groupName = "<your group name>";
// Create a new blob service client using the connection string
BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);
// Get the container client for the specified container name
BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient(containerName);
// Get the blob client for the specified folder name and create a Shared Access Signature (SAS)
BlobClient blobClient = containerClient.GetBlobClient(folderName + "/");
BlobSasBuilder sasBuilder = new BlobSasBuilder()
{
BlobContainerName = containerName,
BlobName = folderName + "/",
Resource = "c",
ExpiresOn = DateTimeOffset.UtcNow.AddDays(1)
};
sasBuilder.SetPermissions(accessLevel);
string sasToken = sasBuilder.ToSasQueryParameters(new Azure.Storage.StorageSharedKeyCredential("<your storage account name>", "<your storage account key>")).ToString();
// Set the access policy for the folder using the SAS token
BlobSignedIdentifier signedIdentifier = new BlobSignedIdentifier()
{
Id = groupName,
AccessPolicy = new BlobAccessPolicy()
{
StartsOn = DateTimeOffset.UtcNow,
ExpiresOn = DateTimeOffset.UtcNow.AddDays(1),
Permissions = accessLevel
}
};
containerClient.SetAccessPolicy(permissions: new BlobSignedIdentifier[] { signedIdentifier });
Console.WriteLine($"Access granted for group {groupName} with access level {accessLevel} to folder {folderName} in container {containerName}.");