title | titleSuffix | description | services | author | ms.author | ms.date | ms.topic | ms.service | ms.custom |
---|---|---|---|---|---|---|---|---|---|
Quickstart: Direct web traffic using Bicep |
Azure Application Gateway |
In this quickstart, you learn how to use Bicep to create an Azure Application Gateway that directs web traffic to virtual machines in a backend pool. |
application-gateway |
schaffererin |
v-eschaffer |
04/14/2022 |
quickstart |
application-gateway |
devx-track-azurepowershell, mvc, subject-armqs, mode-arm |
In this quickstart, you use Bicep to create an Azure Application Gateway. Then you test the application gateway to make sure it works correctly.
[!INCLUDE About Bicep]
- An Azure account with an active subscription. Create an account for free.
This Bicep file creates a simple setup with a public front-end IP address, a basic listener to host a single site on the application gateway, a basic request routing rule, and two virtual machines in the backend pool.
The Bicep file used in this quickstart is from Azure Quickstart Templates
:::code language="bicep" source="~/quickstart-templates/demos/ag-docs-qs/main.bicep":::
Multiple Azure resources are defined in the Bicep file:
- Microsoft.Network/applicationgateways
- Microsoft.Network/publicIPAddresses : one for the application gateway, and two for the virtual machines.
- Microsoft.Network/networkSecurityGroups
- Microsoft.Network/virtualNetworks
- Microsoft.Compute/virtualMachines : two virtual machines
- Microsoft.Network/networkInterfaces : two for the virtual machines
- Microsoft.Compute/virtualMachine/extensions : to configure IIS and the web pages
-
Save the Bicep file as main.bicep to your local computer.
-
Deploy the Bicep file using either Azure CLI or Azure PowerShell.
az group create --name myResourceGroupAG --location eastus az deployment group create --resource-group myResourceGroupAG --template-file main.bicep --parameters adminUsername=<admin-username>
New-AzResourceGroup -Name myResourceGroupAG -Location eastus New-AzResourceGroupDeployment -ResourceGroupName myResourceGroupAG -TemplateFile ./main.bicep -adminUsername "<admin-username>"
[!NOTE] Replace <admin-username> with the admin username for the backend servers. You'll also be prompted to enter adminPassword.
When the deployment finishes, you should see a message indicating the deployment succeeded.
Use the Azure portal, Azure CLI, or Azure PowerShell to list the deployed resources in the resource group.
az resource list --resource-group myResourceGroupAG
Get-AzResource -ResourceGroupName myResourceGroupAG
When no longer needed, use the Azure portal, Azure CLI, or Azure PowerShell to delete the resource group and its resources.
az group delete --name myResourceGroupAG
Remove-AzResourceGroup -Name myResourceGroupAG
[!div class="nextstepaction"] Manage web traffic with an application gateway using the Azure CLI