After spending a lot of additional hours, I finally found a solution to the issue.
First, you have to use the Azure.Storage.Files.Shares Namespace.
using Azure.Storage;
using Azure.Storage.Files.Shares;
using Azure.Storage.Files.Shares.Models;
var shareClient = new ShareClient(new Uri($"https://{storageAccountName}.file.core.windows.net/{shareName}"),
new StorageSharedKeyCredential(storageAccountName, storageAccountKey));
var directoryClient = shareClient.GetDirectoryClient(folderPath);
foreach (var item in directoryClient.GetFilesAndDirectories())
{
var fileClient = directoryClient.GetFileClient(item.Name);
// ShareFileProperties properties = fileClient.GetProperties();
// var permissions = properties.SmbProperties.FilePermissionKey; //to read the existing permissions
var smbProperties = new FileSmbProperties
{
FilePermissionKey = "1234567890123456789*1234567890123456789"
};
var httpHeadersOptions = new ShareFileSetHttpHeadersOptions
{
SmbProperties = smbProperties
};
await fileClient.SetHttpHeadersAsync(httpHeadersOptions);
I still do not know exactly how to "create" a new FilePermissionKey, as this seems to be 19 digit number * 19 digit number.
But If I read the existing permissions form a different file / folder
var permissions = properties.SmbProperties.FilePermissionKey;
And apply the same value to another File or Folder, it does apply the same permissions.
So only thing left is to explore how I can create those required FilePermissionKey values on demand.