除最后两条外,我想删除“集装箱登记册”中的所有图像。 我正在寻找文字,但我只想删除X天以上的图像。 我的情况是不可能做到的,因为有几天来,产生了许多图像,只有一天。
有些人有什么想法?
除最后两条外,我想删除“集装箱登记册”中的所有图像。 我正在寻找文字,但我只想删除X天以上的图像。 我的情况是不可能做到的,因为有几天来,产生了许多图像,只有一天。
有些人有什么想法?
修改电梯和邮局的数值; 姓名与你选择,并用这一文字处理权力。
注:请核实您的当地系统安装了轴心。
$registryName = registryName
$doNotDeleteTags =
$skipLastTags = 4
$repoArray = (az acr repository list --name $registryName --output json | ConvertFrom-Json)
foreach ($repo in $repoArray)
{
$tagsArray = (az acr repository show-tags --name $registryName --repository $repo --orderby time_asc --output json | ConvertFrom-Json ) | Select-Object -SkipLast $skipLastTags
foreach($tag in $tagsArray)
{
if ($donotdeletetags -contains $tag)
{
Write-Output ("This tag is not deleted $tag")
}
else
{
az acr repository delete --name $registryName --image $repo":"$tag --yes
}
}
}
如需要,请在<编码>bash上填写。
The variable delete_from
is 1-index based, i.e. if you specify the value 1, all images will be deleted.
A value of 3 keeps the 2 latest images.
#!/bin/bash -e
acr= your_acr
repos=( repo1 repo2 repoN )
delete_from=3
for repo in "${repos[@]}"; do
tags_to_delete=$(echo $(az acr repository show-tags -n ${acr} --repository ${repo} --orderby time_desc --output tsv) | cut -d -f${delete_from}-)
for tag_to_delete in ${tags_to_delete}; do
az acr repository delete --yes -n ${acr} --image ${repo}:${tag_to_delete}
done
done
现在我无法测试,但这份很少的PowerShell书应当发挥作用:
$acrName = YourACRName
$repo = az acr repository list --name $acrName
$repo | Convertfrom-json | Foreach-Object {
$imageName = $_
(az acr repository show-tags -n $acrName --repository $_ |
convertfrom-json )| Select-Object -SkipLast 2 | Foreach-Object {
az acr repository delete --yes -n $acrName --image "$imageName:$_"
}
}
它检索了每个存放处的所有标签,ski了最后2个,然后在每一tag子上 it,删除。
请首先在
如果加上“最后两条”,就是指
az acr repository show-manifests --name your_acr --repository your_repo --orderby time_desc -o tsv --query [].digest | sed -n 3,$ p | xargs -I% az acr repository delete --name your_acr --image your_repo@% --yes
你们可以利用大楼进行精炼的指挥:
<>斯特凡>
$subscription = "your-subscription-id"
$registry = "your-registry"
$PURGE_CMD = "acr purge --filter acs-weather-api:.* --keep 2 --ago 0d --untagged"
az acr run --cmd $PURGE_CMD --registry $registry --subscription $subscription /dev/null
<>Bash
SUBSCRIPTION="your-subscription-id"
REGISTRY="your-registry"
PURGE_CMD="acr purge --filter acs-weather-api:.* --keep 2 --ago 0d --untagged"
az acr run --cmd "$PURGE_CMD" --registry "$REGISTRY" --subscription "$SUBSCRIPTION" /dev/null
根据@Christian Holm Jørgensen的答复
现在,你可以保留名单(名单)。
#!/bin/bash -e
acr= MY_ACR_NAME
repos=( MY_REPO ) # repo2 repoN )
save_list="0.2.0-alpha.1 latest 1.0.0"
string_remove_pattern() {
echo "${1//$2}"
}
for repo in "${repos[@]}"; do
tags_available=$(echo $(az acr repository show-tags -n "${acr}" --repository "${repo}" --orderby time_desc --output tsv))
for to_save in $save_list; do
tags_available=$(string_remove_pattern "$tags_available" "$to_save")
done
tags_to_delete=$tags_available
echo -e "The follow image, from ACR $acr and repos $repos, will be deleted:
$tags_to_delete"
read -rp "Is the list of image to delete correct? (Y/N)" answer
if [ "$answer" == "Y" ]; then
for tag_to_delete in ${tags_to_delete}; do
az acr repository delete --yes -n "${acr}" --image "${repo}":"${tag_to_delete}"
done
fi
done
您可使用acr purge
s-keep
。
请注意,光电池不是 a子的一部分,但你需要从源头上建造,或从cker窗上使用。
例如,保存3个图像;
acr purge
--registry <Registry Name>
--filter <Repository Filter/Name>:<Regex Filter>
--keep 3
你们也可以把这一点与几天前的过滤结合起来:
acr purge
--registry <Registry Name>
--filter <Repository Filter/Name>:<Regex Filter>
--ago 30d
--keep 3
详情请见acr-cli repo。
Bash Alternative of script given by Manish Bhakuni, which has Superior upvotes.
#!/bin/bash
registryName= registryName
doNotDeleteTags=
skipLastTags=3
repoArray=$(az acr repository list --name "$registryName" --output json)
# Check for errors during command execution
if [[ $? -ne 0 ]]; then
echo "Error: Failed to list repositories"
exit 1
fi
repoArray=($(jq -r .[] <<< "$repoArray"))
for repo in "${repoArray[@]}"; do
# Get tags for the repository (ordered by ascending time)
tagsArray=$(az acr repository show-tags --name "$registryName" --repository "$repo" --orderby time_asc --output json)
# Check for errors during command execution
if [[ $? -ne 0 ]]; then
echo "Error: Failed to list tags for repository $repo "
continue # Skip to the next iteration
fi
# Convert JSON to array and skip the last N tags (using awk)
tagsArray=($(echo "$tagsArray" | jq -r .[] ))
tagsArray=("${tagsArray[@]:0:${#tagsArray}-$skipLastTags}")
for tag in "${tagsArray[@]}"; do
# Check if tag is in the exclusion list
if [[ "$doNotDeleteTags" =~ "$tag" ]]; then
echo "This tag is not deleted: $tag"
else
# Delete the tag using az acr repository delete with confirmation (-y)
az acr repository delete --name "$registryName" --image "$repo:$tag" -y
echo "Deleted $repo:$tag"
# Check for errors during command execution
if [[ $? -ne 0 ]]; then
echo "Error: Failed to delete tag $tag from repository $repo "
fi
fi
done
done
This is a pretty vague question but I m struggling a bit to get my head around what is involved in cloud hosting. Say for instance if I had an asp.net web app using: - Webforms - linq to sql - an ...
I am working on an Azure demo to run Powershell in a worker role. In my web role I add the name of the Powershell script which is to be run to a CloudQueue object. I can print the script output to ...
I ve been struggling with this one for a couple of days now. My current Windows Azure WebRole is stuck in a loop where the status keeps changing between Initializing, Busy, Stopping and Stopped. It ...
We are looking at Windows Azure, but getting a token appears to be hard now, at least that s what I m seeing in web searches. Anyone tried it or know how to accelerate that process? Any idea how long ...
Problem: I have a Azure project. The problem is that when I run the application it takes like 10-15 minutes to actually open the page in browser. The page & debugging works normaly. Project: ...
I am developing a ASP.NET MVC web app under .NET 3.5, NHibernate and hosted on Windows Azure. When, the webapp is run from the local development fabric it works fine. Yet, when I move it to Windows ...
Presently .Net 4.0 is not supported on Azure. This thread indicates that you will not be able to use .Net 4.0 with VS 2010 until it is supported in the cloud. http://social.msdn.microsoft.com I d ...
My google-fu is failing me on this one. As a possible solution to Unit Testing .NET 3.5 projects using MStest in VS2010 (but I ve put this in a seperate question because it s kind of unrelated): Is ...