我想更改azure webapp设置,并且能够通过以下Powershell代码来实现。如您所见,有变量及其值,我想动态地调用变量及其值并通过使用命令一次遍历它。有办法实现吗

az webapp config appsettings set -g $resourceGroup -n $webAppName --settings ApplicationInsightsAgent_EXTENSION_VERSION="~2"
az webapp config appsettings set -g $resourceGroup -n $webAppName --settings APPINSIGHTS_PROFILERFEATURE_VERSION="1.0.0"
az webapp config appsettings set -g $resourceGroup -n $webAppName --settings APPINSIGHTS_SNAPSHOTFEATURE_VERSION="1.0.0"
az webapp config appsettings set -g $resourceGroup -n $webAppName --settings XDT_MicrosoftApplicationInsights_BaseExtensions="disabled"
az webapp config appsettings set -g $resourceGroup -n $webAppName --settings XDT_MicrosoftApplicationInsights_Mode="recommended"
az webapp config appsettings set -g $resourceGroup -n $webAppName --settings DiagnosticServices_EXTENSION_VERSION="~3"
az webapp config appsettings set -g $resourceGroup -n $webAppName --settings SnapshotDebugger_EXTENSION_VERSION="disabled"
az webapp config appsettings set -g $resourceGroup -n $webAppName --settings InstrumentationEngine_EXTENSION_VERSION="disabled"

最佳答案

使用powershell + az cli进行此操作的最简单方法:

'ApplicationInsightsAgent_EXTENSION_VERSION="~2"',xxx,'InstrumentationEngine_EXTENSION_VERSION="disabled"' | Foreach-Object {
    az webapp config appsettings set -g $resourceGroup -n $webAppName --settings $_
}

您也可以使用xargs在没有powershell的情况下实现相同的效果

关于azure - 如何在Powershell/Azure CLI中动态遍历键值对,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/60588752/

10-11 22:22
查看更多