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

标签 powershell azure-resource-manager azure-application-gateway

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

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

关于powershell - 应用程序网关路由规则未使用 powershell 脚本更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50980817/

相关文章:

powershell - 从 2 个哈希表中选择重复的键值

linux - 将文件从 Windows 传输到 Linux,而无需使用第 3 方软件且仅使用 Shell.Application

azure - 将状态保留到 Azure Service Fabric 中的附加磁盘

json - 将结果保存到变量时 PowerShell shell 挂起(Azure 管道列表)

azure - 为什么我可以在 Visual Studio 之外运行此 Azure 资源组部署脚本?

python - 使用 Azure 资源管理器 REST API

带有应用服务 Web 应用的 Azure 应用程序网关

应用程序网关前面的 Azure 前门

azure - 使用Azure应用程序网关时可以删除Nginx吗?

python - 在VBA Outlook中运行Python或PowerShell