Azure应用程序网关重定向配置

时间:2018-05-03 10:57:55

标签: powershell azure

我已经创建了一个power-shell脚本,可以将重定向配置添加到Azure应用程序网关服务中的外部站点。

$AppgwName = "appgwname"
$rgName = "rgname"
$Externalsite = "http://www.google.com"
$RedirectConfigurationName = "name of the redirect config"
$listnerName = "listner name"
$redirectrulename = "existing rule name "

$gw = Get-AzureRmApplicationGateway -Name $AppgwName -ResourceGroupName 
$rgName
Add-AzureRmApplicationGatewayRedirectConfiguration -Name 
$RedirectConfigurationName -RedirectType Temporary -TargetUrl $Externalsite 
-ApplicationGateway $gw
$defaultListener = Get-AzureRmApplicationGatewayHttpListener -Name 
$listnerName -ApplicationGateway $gw
$redirectConfig = Get-AzureRmApplicationGatewayRedirectConfiguration -Name 
$RedirectConfigurationName -ApplicationGateway $gw
$redirectRule =  Set-AzureRmApplicationGatewayRequestRoutingRule -Name 
$redirectrulename -RuleType Basic -HttpListener $defaultListener - 
RedirectConfiguration $redirectConfig -ApplicationGateway $gw
Set-AzureRmApplicationGateway -ApplicationGateway $gw

脚本效果很好! ! !但是当我尝试删除配置时遇到错误。

$gw = Get-AzureRmApplicationGateway -Name $AppgwName -ResourceGroupName 
$rgName
$gw = Remove-AzureRmApplicationGatewayRedirectConfiguration -Name 
$RedirectConfigurationName -ApplicationGateway $gw
Set-AzureRmApplicationGatewayRequestRoutingRule -Name $redirectrulename - 
RuleType Basic -HttpListener $defaultListener -ApplicationGateway $gw - 
BackendAddressPool $backendpool
Set-AzureRmApplicationGateway -ApplicationGateway $gw

Error ref

不知道我的删除脚本是否配置正确,请帮我解决这个问题。

谢谢:)

0 个答案:

没有答案