Specify your http header rewrite rule configuration
Specify autoscale
Create the application gateway
Test the application gateway
If you don't have an Azure subscription, create a free account before you begin.
Prerequisites
This article requires that you run Azure PowerShell locally. You must have Az module version 1.0.0 or later installed. Run Import-Module Az and thenGet-Module Az to find the version. If you need to upgrade, see Install Azure PowerShell module. After you verify the PowerShell version, run Login-AzAccount to create a connection with Azure.
Create a resource group in one of the available locations.
$location = "East US 2"
$rg = "<rg name>"
#Create a new Resource Group
New-AzResourceGroup -Name $rg -Location $location
Create a virtual network
Create a virtual network with one dedicated subnet for an autoscaling application gateway. Currently only one autoscaling application gateway can be deployed in each dedicated subnet.
Specify the allocation method of PublicIPAddress as Static. An autoscaling application gateway VIP can only be static. Dynamic IPs are not supported. Only the standard PublicIpAddress SKU is supported.
#Create static public IP
$pip = New-AzPublicIpAddress -ResourceGroupName $rg -name "AppGwVIP" `
-location $location -AllocationMethod Static -Sku Standard
Retrieve details
Retrieve details of the resource group, subnet, and IP in a local object to create the IP configuration details for the application gateway.
Configure the IP config, frontend IP config, backend pool, HTTP settings, certificate, port, and listener in an identical format to the existing Standard application gateway. The new SKU follows the same object model as the Standard SKU.
Specify your HTTP header rewrite rule configuration
Configure the new objects required to rewrite the http headers:
RequestHeaderConfiguration: this object is used to specify the request header fields that you intend to rewrite and the new value that the original headers need to be rewritten to.
ResponseHeaderConfiguration: this object is used to specify the response header fields that you intend to rewrite and the new value that the original headers need to be rewritten to.
ActionSet: this object contains the configurations of the request and response headers specified above.
RewriteRule: this object contains all the actionSets specified above.
RewriteRuleSet- this object contains all the rewriteRules and will need to be attached to a request routing rule - basic or path-based.
Create a request routing rule. Once created, this rewrite configuration is attached to the source listener via the routing rule. When using a basic routing rule, the header rewrite configuration is associated with a source listener and is a global header rewrite. When a path-based routing rule is used, the header rewrite configuration is defined on the URL path map. So, it only applies to the specific path area of a site. Below, a basic routing rule is created and the rewrite rule set is attached.
Use Get-AzPublicIPAddress to get the public IP address of the application gateway. Copy the public IP address or DNS name, and then paste it into the address bar of your browser.
First explore the resources that were created with the application gateway. Then, when they're no longer needed, you can use the Remove-AzResourceGroup command to remove the resource group, application gateway, and all related resources.
In this module, you'll learn to improve application resilience by distributing load across multiple servers and use path-based routing to direct web traffic.