Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Create an Azure Web App with Azure Resource Manager Templates

May 7, 2020 • 6 Minute Read

Introduction

When creating a resource in Azure, you have two options: manually click buttons or automate the creation. Automating the resources and services to deploy is, of course, the best option. Not only is it faster and more reliable, but it's also easier to scale and can be used throughout teams as well as departments. When thinking about infrastructure and Azure resource automation, the best player in the game is Infrastructure-as-Code (IaS), which codifies the way you create infrastructure-related resources.

Azure Resource Manager (ARM) is the native Infrastructure-as-Code language created by Microsoft. ARM templates are written in a JSON-like format and provide the ability to create Azure resources based on API calls to Azure.

In this guide you will learn how to create an Azure web app using ARM templates. Learning how to deploy web apps with ARM will allow you to completely revamp and scale the way you are using serverless in Azure.

Prerequisites

To follow along with this guide, you should have:

  • An Azure subscription. If you don't have one, you can create a 30-day free trial here.
  • A text editor, preferably Visual Studio (VS) Community Edition, which you can find here.

Creating the ARM Template Project in Visual Studio

Figuring out which solution to use to deploy code can be cumbersome. Although many methods are straight-forward, there are just so many. How do you know which one to choose?

When deploying an ARM template, one of the easiest and most efficient ways is deploying via Visual Studio. Visual Studio has ARM templates built in that you can deploy by simply right-clicking the project and choosing deploy.

Open Visual Studio and create a new project for the ARM template to be created in.

Under project templates, look for Azure Resource Group, which are templates for interacting with Azure from Visual Studio Code.

Give the project a name and click the Create button.

After clicking the create button, there will be a Select Azure Template screenshot that comes up with pre-made ARM templates called QuickStart Templates.

In the Search bar, type webapp. The webapp template you will want to choose is 101-webapp-basic-linux, which will create a basic web app template. After you choose the template, click the OK button.

The solution will now open in Visual Studio. You will see a few configurations in the Solution Explorer. Open up the azuredeploy.json as shown in the screenshot below.

The azuredeploy.json configuration is what holds the deployment instructions for the Azure Web App, specifically, the code below which is the API call to Azure App Services. Sometimes the azuredeploy.json template is also referred to as the main template.

      {
      "type": "Microsoft.Web/sites",
      "apiVersion": "2018-11-01",
      "name": "[variables('webAppPortalName')]",
      "location": "[parameters('location')]",
      "kind": "app",
      "dependsOn": [
        "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]"
      ],
      "properties": {
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]",
        "siteConfig": {
            "linuxFxVersion": "[parameters('linuxFxVersion')]"
          }
      }
    }
    

Deploying the ARM Template in Visual Studio

In the previous section you learned how to create an ARM template using the Azure QuickStart templates in Visual Studio. Using the QuickStart templates allows you to have a ready-to-go ARM configuration that you can modify if needed, but you don't have to write it from scratch.

To deploy the ARM template, within Visual Studio, right click on the project name. In the screenshot below, the project name is webapp.

Choose Deploy —> New to deploy the Azure Web App to Azure.

You will be presented with the Deploy to Resource Group screen. Choose the appropriate subscription and resource group, and click the grey Deploy button.

After clicking deploy, you will see output similar to the screenshot below stating that the deployment is underway.

When the deployment is finished, an output like in the screenshot below will show.

Confirming the Deployment in Azure

Now that the Azure web app is deployed, it's time to confirm the successful deployment by logging into the Azure web portal and going to the App Services blade.

Open up a web browser and go to the App Services blade.

As shown in the screenshot below, the new web app has been created.

Conclusion

In this guide you took a hands-on approach at deploying an Azure web app. You first learned how to create the app by using the Azure QuickStart templates in Visual Studio. After the QuickStart template was selected, you took a look at the Azure Resource Manager code and saw the API that creates the Azure web app. After you created the ARM template and took a look at the code, you deployed the Azure web app from Visual Studio. After the web app was deployed and you saw the successful output from Visual Studio, you confirmed the web app was created by logging into the Azure web portal and going to the App Services blade.