title | description | services | author | manager | editor | tags | ms.service | ms.topic | ms.workload | ms.date | ms.author |
---|---|---|---|---|---|---|---|---|---|---|---|
Create an application gateway with URL path-based routing rules - Azure portal | Microsoft Docs |
Learn how to create URL path-based routing rules for an application gateway and virtual machine scale set using the Azure portal. |
application-gateway |
vhorne |
jpconnock |
tysonn |
azure-resource-manager |
application-gateway |
article |
infrastructure-services |
10/25/2018 |
victorh |
You can use the Azure portal to configure URL path-based routing rules when you create an application gateway. In this tutorial, you create backend pools using virtual machines. You then create routing rules that make sure web traffic arrives at the appropriate servers in the pools.
In this article, you learn how to:
[!div class="checklist"]
- Create an application gateway
- Create virtual machines for backend servers
- Create backend pools with the backend servers
- Create a backend listener
- Create a path-based routing rule
If you prefer, you can complete this tutorial using Azure CLI or Azure PowerShell.
If you don't have an Azure subscription, create a free account before you begin.
Log in to the Azure portal at https://portal.azure.com
A virtual network is needed for communication between the resources that you create. Two subnets are created in this example: one for the application gateway, and the other for the backend servers. You can create a virtual network at the same time that you create the application gateway.
-
Click New found on the upper left-hand corner of the Azure portal.
-
Select Networking and then select Application Gateway in the Featured list.
-
Enter these values for the application gateway:
- myAppGateway - for the name of the application gateway.
- myResourceGroupAG - for the new resource group.
-
Accept the default values for the other settings and then click OK.
-
Click Choose a virtual network, click Create new, and then enter these values for the virtual network:
- myVNet - for the name of the virtual network.
- 10.0.0.0/16 - for the virtual network address space.
- myAGSubnet - for the subnet name.
- 10.0.0.0/24 - for the subnet address space.
-
Click OK to create the virtual network and subnet.
-
Click Choose a public IP address, click Create new, and then enter the name of the public IP address. In this example, the public IP address is named myAGPublicIPAddress. Accept the default values for the other settings and then click OK.
-
Accept the default values for the Listener configuration, leave the Web application firewall disabled, and then click OK.
-
Review the settings on the summary page, and then click OK to create the network resources and the application gateway. It may take several minutes for the application gateway to be created, wait until the deployment finishes successfully before moving on to the next section.
-
Click All resources in the left-hand menu, and then click myVNet from the resources list.
-
Click Subnets, and then click Subnet.
-
Enter myBackendSubnet for the name of the subnet and then click OK.
In this example, you create three virtual machines to be used as backend servers for the application gateway. You also install IIS on the virtual machines to verify that the application gateway was successfully created.
-
Click New.
-
Click Compute and then select Windows Server 2016 Datacenter in the Featured list.
-
Enter these values for the virtual machine:
- myVM1 - for the name of the virtual machine.
- azureuser - for the administrator user name.
- Azure123456! for the password.
- Select Use existing, and then select myResourceGroupAG.
-
Click OK.
-
Select DS1_V2 for the size of the virtual machine, and click Select.
-
Make sure that myVNet is selected for the virtual network and the subnet is myBackendSubnet.
-
Click Disabled to disable boot diagnostics.
-
Click OK, review the settings on the summary page, and then click Create.
-
Open the interactive shell and make sure that it is set to PowerShell.
-
Run the following command to install IIS on the virtual machine:
$publicSettings = @{ "fileUris" = (,"https://raw.githubusercontent.com/Azure/azure-docs-powershell-samples/master/application-gateway/iis/appgatewayurl.ps1"); "commandToExecute" = "powershell -ExecutionPolicy Unrestricted -File appgatewayurl.ps1" } Set-AzureRmVMExtension ` -ResourceGroupName myResourceGroupAG ` -Location eastus ` -ExtensionName IIS ` -VMName myVM1 ` -Publisher Microsoft.Compute ` -ExtensionType CustomScriptExtension ` -TypeHandlerVersion 1.4 ` -Settings $publicSettings
-
Create two more virtual machines and install IIS using the steps that you just finished. Enter the names of myVM2 and myVM3 for the names and for the values of VMName in Set-AzureRmVMExtension.
-
Click All resources and then click myAppGateway.
-
Click Backend pools. A default pool was automatically created with the application gateway. Click appGateayBackendPool.
-
Click Add target to add myVM1 to appGatewayBackendPool.
-
Click Save.
-
Click Backend pools and then click Add.
-
Enter a name of imagesBackendPool and add myVM2 using Add target.
-
Click OK.
-
Click Add again to add another backend pool with a name of videoBackendPool and add myVM3 to it.
- Click Listeners and the click Basic.
- Enter myBackendListener for the name, myFrontendPort for the name of the frontend port, and then 8080 as the port for the listener.
- Click OK.
-
Click Rules and then click Path-based.
-
Enter rule2 for the name.
-
Enter Images for the name of the first path. Enter /images/* for the path. Select imagesBackendPool for the backend pool.
-
Enter Video for the name of the second path. Enter /video/* for the path. Select videoBackendPool for the backend pool.
-
Click OK.
-
Click All resources, and then click myAGPublicIPAddress.
-
Copy the public IP address, and then paste it into the address bar of your browser. Such as, http://40.121.222.19.
-
Change the URL to http://<ip-address>:8080/images/test.htm, substituting <ip-address> with your IP address, and you should see something like the following example:
-
Change the URL to http://<ip-address>:8080/video/test.htm, substituting <ip-address> with your IP address, and you should see something like the following example:
In this article, you learned how to
[!div class="checklist"]
- Create an application gateway
- Create virtual machines for backend servers
- Create backend pools with the backend servers
- Create a backend listener
- Create a path-based routing rule
To learn more about application gateways and their associated resources, continue to the how-to articles.