gpt4 book ai didi

azure - 如何使用 Azure CLI 列出 Web 应用程序扩展?

转载 作者:行者123 更新时间:2023-12-03 05:11:32 24 4
gpt4 key购买 nike

我需要删除大约 50 个 Azure 应用服务中的站点扩展。az webapp 命令空间未列出任何网站扩展名: https://learn.microsoft.com/en-us/cli/azure/webapp?view=azure-cli-latest

Azure 团队不会触及网站扩展:https://github.com/Azure/azure-cli/issues/7617

但是,注释显示如果您知道资源 ID,则可以删除扩展: https://github.com/Azure/azure-cli/issues/7617#issuecomment-952743871

此命令不返回已安装的扩展:

az resource list --resource-type Microsoft.Web/sites

此命令不返回任何内容:

az resource list --resource-type Microsoft.Web/sites/siteextensions

那么如何使用 Azure CLI 获取已安装的 Web 应用扩展的列表?

最佳答案

即使我无法使用 az resources list --resource-type Microsoft.Web/sites 命令获取扩展列表。

enter image description here

使用 show az resources show 而不是 az 资源列表

az resource show --resource-group 'YourRGName' --resource-type 'Microsoft.Web/sites/siteextensions'  --name 'mywebapp15June/siteextensions'                    

enter image description here

  • 仅当我们提供 Web 应用程序名称时,此命令才有效。一次,我们只能检索 1 个 Web 应用程序。
  • 要检索所有网络应用程序的扩展,需要循环运行上述命令。

我尝试使用 Bash 循环运行该命令。

RG="YourRGName"
AppNames=$(az webapp list --resource-group $RG --query "[].name" -o tsv)

for AppName in $AppNames; do
echo "WebApp: $AppName"

extensions=$(az resource show --resource-group $RG --resource-type Microsoft.Web/sites/siteextensions --name "$AppName/siteextensions")

echo "Site Extensions:"
echo $extensions.title
echo "=========================="
done

输出:

enter image description here

enter image description here

将列出安装了扩展的 Web 应用程序。

关于azure - 如何使用 Azure CLI 列出 Web 应用程序扩展?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76485719/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com