应用程序网关路由规则未使用 powershell 脚本更新

Application gateway routing rule not updating with powershell script

我正在使用以下脚本尝试更新我的应用程序网关中的路由规则。它运行良好,没有错误,但当我去检查规则时似乎实际上没有做任何事情,它与 运行 脚本之前的规则相同:

Write-Host "Logging in...";
Login-AzureRmAccount

Write-Host "Selecting Subscription";
Select-AzureRmSubscription -SubscriptionId "id"

Write-Host "Get application gateway, settings and pool";
$AppGw = Get-AzureRmApplicationGateway -Name "name" -ResourceGroupName "rg"
$Settings  = Get-AzureRmApplicationGatewayBackendHttpSettings -Name "MaintenanceHTTPSetting" -ApplicationGateway $AppGw
$BackendPool = Get-AzureRmApplicationGatewayBackendAddressPool -Name "maintenancePool" -ApplicationGateway $AppGw

Write-Host $Appgw
Write-Host "Configure gateway rule";
Set-AzureRmApplicationGatewayRequestRoutingRule -ApplicationGateway $AppGw -Name "rule1" -RuleType Basic -BackendHttpSettings $Settings -BackendAddressPool $BackendPool

任何关于我可能哪里出错的提示我都不是很熟悉 powershell,它没有给我太多关于发生的事情的信息。

Set-AzureRmApplicationGatewayRequestRoutingRule cmdlet 仅修改内存中的路由规则,不会将其提交给应用程序网关。

为了解决这个问题,应该使用以下代码片段来与上面的代码片段进行比较:

Write-Host "Selecting Subscription";
Select-AzureRmSubscription -SubscriptionId "id"

Write-Host "Get application gateway, settings and pool";
$AppGw = Get-AzureRmApplicationGateway -Name "name" -ResourceGroupName "rg"
$Settings  = Get-AzureRmApplicationGatewayBackendHttpSettings -Name "MaintenanceHTTPSetting" -ApplicationGateway $AppGw
$BackendPool = Get-AzureRmApplicationGatewayBackendAddressPool -Name "maintenancePool" -ApplicationGateway $AppGw

Write-Host "Configure gateway rule";
$AppGw = Set-AzureRmApplicationGatewayRequestRoutingRule -ApplicationGateway $AppGw -Name "rule1" -RuleType Basic -BackendHttpSettings $Settings -BackendAddressPool $BackendPool
Write-Host $AppGw;
Set-AzureRmApplicationGateway -ApplicationGateway $AppGw

但是在执行此操作时遇到了另一个问题,该问题已在此处提出但仍未解决:https://github.com/Azure/azure-powershell/issues/3800