github - Azure devops 使用 devops 中的 powershell 脚本路径任务在 ADLS gen2 容器中分配角色 rwx
问题描述
我在将角色分配给存储容器 rwx 时面临一个问题,以便我的数据工厂可以从 adls gen 2 读取数据。下面的脚本在 azure devops powershell 脚本中使用内联脚本运行良好。但是当我将其更改为来自文件路径的脚本时(位置是github)。我已经在 .ps1 扩展名中放入了以下脚本。
[CmdletBinding()]
param(
[parameter(Mandatory = $false)] [String] $resourcegroup_name,
[parameter(Mandatory = $false)] [String] $factoryName,
[parameter(Mandatory = $false)] [String] $storageaccount_name
)
$principalID = (Get-AzDataFactoryV2 -ResourceGroupName $resourcegroup_name -Name
$factoryName).identity.PrincipalId
$storageAccount = Get-AzStorageAccount -ResourceGroupName $resourcegroup_name -AccountName
$storageaccount_name
$ctx = $storageAccount.Context
$filesystemName = "adftransformation"
$dirname = "mfg/"
$dir = New-AzDataLakeGen2Item -Context $ctx -FileSystem $filesystemName -Path $dirname -Directory -
Permission r-x -Umask ---rwx--- -Property @{"ContentEncoding" = "UDF8"; "CacheControl" = "READ"}
$acl = (Get-AzDataLakeGen2Item -Context $ctx -FileSystem $filesystemName -Path $dirname).ACL
$acl = set-AzDataLakeGen2ItemAclObject -AccessControlType user -EntityID $principalID -Permission r-x
-InputObject $acl
Update-AzDataLakeGen2Item -Context $ctx -FileSystem $filesystemName -Path $dirname -Acl $acl
我在 devops 管道中遇到的错误
2020-06-03T14:29:18.8399468Z ##[错误]无法验证参数“权限”的参数。参数“rx”与“([r-][w-][x-]){3}”模式不匹配。提供与“([r-] [w-][x-]){3}”匹配的参数并再次尝试该命令。
我不确定为什么在选择脚本作为文件路径时会发生这种情况,相同的脚本在内联脚本路径中运行良好
解决方案
This is the correct script from Githubif you are taking as a file path.
[CmdletBinding()]
param(
[parameter(Mandatory = $false)] [String] $resourcegroup_name,
[parameter(Mandatory = $false)] [String] $factoryName,
[parameter(Mandatory = $false)] [String] $storageaccount_name
)
$principalID = (Get-AzDataFactoryV2 -ResourceGroupName $resourcegroup_name -Name
$factoryName).identity.PrincipalId
$storageAccount = Get-AzStorageAccount -ResourceGroupName $resourcegroup_name -
AccountName $storageaccount_name
$ctx = $storageAccount.Context
$filesystemName = "fsname"
$dirname = "mfg/"
$dir = New-AzDataLakeGen2Item -Context $ctx -FileSystem $filesystemName -Path $dirname
-Directory -Permission rwxrwxrwx -Umask ---rwx--- -Property @{"ContentEncoding" =
"UDF8"; "CacheControl" = "READ"}
$acl = (Get-AzDataLakeGen2Item -Context $ctx -FileSystem $filesystemName -Path
$dirname).ACL
$acl = set-AzDataLakeGen2ItemAclObject -AccessControlType user -EntityID $principalID
-Permission rwx -InputObject $acl
Update-AzDataLakeGen2Item -Context $ctx -FileSystem $filesystemName -Path $dirname -
Acl $acl
推荐阅读
- angular - 在 Angular 中获取选定的名称选项卡
- javascript - 一次下载两个 URL,但在一个完成后立即处理
- json - 在颤振中使用 REST API 将新用户添加到 wordpress
- python - C++ 和 Python 实现之间的不同伪随机数
- mysql - mysqldump后mysql数据库大小不同?
- spring - 如何在 JPA 中获取“按区域计算实体”的列表?
- python - Scrapy 的网络图输出
- postgresql - 带有 Docker 图像的 Gitlab CI - Flask 微服务测试数据库
- sql - 使用条件表达式在 SQL 中对数据集求和
- python - 如何在 PySpark 中聚合中位数和标准差?