Last active
February 24, 2020 14:47
-
-
Save jdmsft/a9f213e6dcd2e183d5d2df1141431be9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the application gateway | |
$gw = Get-AzApplicationGateway -Name ApplicationGateway -ResourceGroupName "MyWAF" | |
# Get the existing HTTPS listener, because it had already exists | |
$httpslistener = Get-AzApplicationGatewayHttpListener -Name appGatewayHttpsListener -ApplicationGateway $gw | |
# Get the HTTP listener, because it had already exists | |
$listener = Get-AzApplicationGatewayHttpListener -Name appGatewayHttpListener -ApplicationGateway $gw | |
# Add a redirection configuration using a permanent redirect and targeting the existing listener | |
Add-AzApplicationGatewayRedirectConfiguration -Name redirectHttptoHttps -RedirectType Permanent -TargetListener $httpslistener -IncludePath $true -IncludeQueryString $true -ApplicationGateway $gw | |
# Get the redirect configuration | |
$redirectconfig = Get-AzApplicationGatewayRedirectConfiguration -Name redirectHttptoHttps -ApplicationGateway $gw | |
# Add a new rule to handle the redirect and use the new listener | |
Add-AzApplicationGatewayRequestRoutingRule -Name "HTTPRule_RedirectToHTTPS" -RuleType Basic -HttpListener $listener -RedirectConfiguration $redirectconfig -ApplicationGateway $gw | |
# Update the application gateway | |
Set-AzApplicationGateway -ApplicationGateway $gw |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment