使用PowerShell为不同用户授予对单独的Data Lake Gen 2文件夹的访问权限

问题描述 投票:0回答:1

尽管我可以使用Powershell授予Azure Data Lake Gen 2中的不同用户访问权限,但我希望能够授予访问权限,以便每个用户可以使用每个Data Lake Gen 2容器访问自己的单独文件夹,例如在容器1中,用户A可以访问子文件夹A,而用户B可以访问子文件夹B。这可以使用Storage Explorer UI来实现,但是我无法使用PowerShell命令来实现。

powershell automation azure-powershell azure-data-lake azure-data-lake-gen2
1个回答
0
投票

您可以使用下面的脚本向用户授予权限。

[在我的示例中,我有一个容器test,有两个文件夹,folder1folder2。我在rwx中向用户授予folder1权限。

$storageAccount = Get-AzStorageAccount -ResourceGroupName "xxxxx" -AccountName "joygen"
$ctx = $storageAccount.Context

$filesystemName = "test"
$dirname = "folder1/"
$objectid = "<object-id of the user in Azure AD>"
$acl = New-AzDataLakeGen2ItemAclObject -AccessControlType user -EntityId $objectid -Permission rwx
Update-AzDataLakeGen2Item -Context $ctx -FileSystem $filesystemName -Path $dirname -Acl $acl

获得许可后,我们可以通过以下方式进行检查:

$dir = Get-AzDataLakeGen2Item -Context $ctx -FileSystem $filesystemName -Path $dirname
$dir.ACL

enter image description here

对于其他用户,只需使用脚本将权限授予folder2

© www.soinside.com 2019 - 2024. All rights reserved.