Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Get the application gateway
- $gw = Get-AzureRmApplicationGateway -Name DHProductionGatewayFE -ResourceGroupName DeployHandler
- # Get the existing HTTPS listener
- $httpslistener = Get-AzureRmApplicationGatewayHttpListener -Name appgatewayhttplistener -ApplicationGateway $gw
- # Get the existing front end IP configuration
- $fipconfig = Get-AzureRmApplicationGatewayFrontendIPConfig -Name appgatewayfrontendip -ApplicationGateway $gw
- # Add a new front end port to support HTTP traffic
- Add-AzureRmApplicationGatewayFrontendPort -Name appGatewayFrontendPort2 -Port 80 -ApplicationGateway $gw
- # Get the recently created port
- $fp = Get-AzureRmApplicationGatewayFrontendPort -Name appGatewayFrontendPort2 -ApplicationGateway $gw
- # Create a new HTTP listener using the port created earlier
- Add-AzureRmApplicationGatewayHttpListener -Name appgatewayhttplistener2 -Protocol Http -FrontendPort $fp -FrontendIPConfiguration $fipconfig -ApplicationGateway $gw
- # Get the new listener
- $listener = Get-AzureRmApplicationGatewayHttpListener -Name appgatewayhttplistener2 -ApplicationGateway $gw
- # Add a redirection configuration using a permanent redirect and targeting the existing listener
- Add-AzureRmApplicationGatewayRedirectConfiguration -Name redirectHttptoHttps -RedirectType Permanent -TargetListener $httpslistener -IncludePath $true -IncludeQueryString $true -ApplicationGateway $gw
- # Get the redirect configuration
- $redirectconfig = Get-AzureRmApplicationGatewayRedirectConfiguration -Name redirectHttptoHttps -ApplicationGateway $gw
- # Add a new rule to handle the redirect and use the new listener
- Add-AzureRmApplicationGatewayRequestRoutingRule -Name rule02 -RuleType Basic -HttpListener $listener -RedirectConfiguration $redirectconfig -ApplicationGateway $gw
- # Update the application gateway
- Set-AzureRmApplicationGateway -ApplicationGateway $gw
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement