我正在尝试从所有存储库中清理一些 Azure 容器注册表映像。现在我正在一一输入存储库名称,但这看起来很乏味。
PURGE_CMD="acr purge --filter 'aag:.*' --filter 'aap_6.0:.*' --ago 1d --untagged --keep 7"
az acr task create --name PurgeACRImages \
--cmd "$PURGE_CMD" \
--schedule "5 6 * * 1" \
--registry myregistry \
--timeout 18000 \
--context /dev/null
Run Code Online (Sandbox Code Playgroud)
这里我给出了两个存储库的名称,现在我有 800 个存储库,并且在这个 PURGE_CMD 命令中键入 800 个存储库确实很困难。
我需要一个命令,通过它我可以从 ACR 选择所有存储库并将其存储到 PURGE_CMD 中
我有以下脚本用于从 Azure DevOps 项目生成发布报告。
$token="**************************************************************"
$url="https://dev.azure.com/{orgnization}/_apis/projects?api-version=6.0"
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)"))
$response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "Basic $token"} -Method Get -ContentType application/json
Foreach($projectName in $response.value.name)
{
$url1="https://vsrm.dev.azure.com/{orgnization}/$($projectname)/_apis/release/releases?api-version=6.0"
$response = Invoke-RestMethod -Uri $url1 -Headers @{Authorization = "Basic $token"} -Method Get -ContentType application/json-patch
echo $response | ConvertTo-Json -Depth 99 | Out-File "D:\\file.json" -Append
}
Run Code Online (Sandbox Code Playgroud)
在此脚本中,第一个 API 仅返回 100 条记录。当我尝试添加顶部参数以返回更多记录(如下所示)时,它不会返回任何内容。我在这里做错了什么吗?
https://dev.azure.com/uniperteamservices/_apis/projects?api-version=6.0&$top=500
Run Code Online (Sandbox Code Playgroud)
您能否建议我如何在 REST API url 中添加可在上面的 PowerShell 脚本中运行的 top 参数?
rest powershell azure-powershell azure-devops azure-devops-rest-api