【发布时间】:2018-01-03 13:12:46
【问题描述】:
我正在尝试使用 Azure PowerShell 清除 Web 应用站点配置上的所有应用程序设置和连接字符串。 API 似乎不支持这一点。
我尝试过使用:
Set-AzureRmWebApp -ResourceGroupName $resourceGroupName -Name $siteName -AppSettings @{}
但这会引发错误,因为字典是空的。
我试过使用这个命令:
Set-AzureRmResource -ResourceGroupName $resourceGroupName -ResourceName "$siteName/appsettings" -ResourceType "Microsoft.Web/sites/config" -ApiVersion 2016-08-01 -Properties @{}
但我收到一条错误消息<Error><Message>The requested resource does not support http method 'GET'.</Message></Error>
我也试过这个:
Invoke-AzureRmResourceAction -ResourceGroupName $resourceGroupName -ResourceName "$siteName/appsettings" -ResourceType "Microsoft.Web/sites/config" -ApiVersion 2016-08-01 -Action "Post" -Parameters @{}
但我再次收到此错误:
Cannot validate argument on parameter 'Parameters'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try
the command again.
还有其他清除所有应用设置的方法吗?
以前有一种方法可以使用Get-AzureRmWebApp检索webapp,在本地编辑,然后使用Set-AzureRmWebApp发布对象,实际上帮助文档中还是说有-WebApp参数,但是没有不再存在于最新的 Azure PowerShell 中。
【问题讨论】:
-
是否尝试过获取资源以查看其外观?然后只发送一个空集合?
-
我在实验室测试,null 值不允许传递给-AppSettings。
标签: powershell azure azure-powershell