我正尝试通过Azure Cli从给定的资源组中删除部署(因为它达到800个最大值),如下所示。但是下面的脚本不起作用。有人知道吗?
az Login
az account set --subscription "mysubscription"
$resourceGroupName = "myresourcegroup"
$deployments = az group deployment list --resource-group $resourceGroupName
Foreach ($deployment in $deployments)
{
az group deployment delete --name $deployment.name --resource-group $resourceGroupName
}
-艾伦-
答案 0 :(得分:0)
发生这种情况是因为az cli输出的是json,而不是对象。您需要将其强制转换为对象才能起作用:
$deployments = ( az group deployment list --resource-group $resourceGroupName ) |
ConvertFrom-Json
Foreach ($deployment in $deployments) {
az group deployment delete --name $deployment.name --resource-group $resourceGroupName
}