Deploy a Website using Azure CLI and ARM Template

Deploying a website to Azure can be a straightforward process, especially when you leverage the power of Azure CLI and ARM (Azure Resource Manager) templates. This guide will walk you through the steps of deploying a website using these tools, from set…


This content originally appeared on DEV Community and was authored by Tracy Chinedu

Deploying a website to Azure can be a straightforward process, especially when you leverage the power of Azure CLI and ARM (Azure Resource Manager) templates. This guide will walk you through the steps of deploying a website using these tools, from setting up your environment to deploying your site. Let’s dive in!

Prerequisites

Before we get started, make sure you have the following:

Azure Account: If you don’t have one, sign up for a free Azure account here.
Azure CLI: Install Azure CLI on your machine. You can download it from the official site.
Text Editor: You’ll need a text editor to write your ARM template. Visual Studio Code is a popular choice.

Prepare ARM Template
ARM (Azure Resource Manager) templates are JSON files that define the infrastructure and configuration for your Azure resources.
Here's a simple ARM template to deploy an Azure Web App:

Template.json File:


{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "resources": [
      {
        "type": "Microsoft.Web/serverfarms",
        "apiVersion": "2021-01-15",
        "name": "[parameters('appServicePlanName')]",
        "location": "[resourceGroup().location]",
        "sku": {
          "name": "F1",
          "tier": "Free",
          "size": "F1",
          "family": "F",
          "capacity": 1
        }
      },
      {
        "type": "Microsoft.Web/sites",
        "apiVersion": "2021-01-15",
        "name": "[parameters('webAppName')]",
        "location": "[resourceGroup().location]",
        "properties": {
          "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName'))]",
          "siteConfig": {
            "appSettings": [
              {
                "name": "SCM_DO_BUILD_DURING_DEPLOYMENT",
                "value": "true"
              }
            ]
          }
        }
      }
    ],
    "parameters": {
      "appServicePlanName": {
        "type": "string"
      },
      "webAppName": {
        "type": "string"
      }
    }
  }

Customize ARM Parameters
Parameters.json file:

`{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "appServicePlanName": {
      "value": "TracyServicePlan"
    },
    "webAppName": {
      "value": "ChineduOnyinye78"
    }
  }
}

Deploy the ARM Template using Azure CLI:

  • First, make sure you have the Azure CLI installed. You can download it from the Azure CLI installation page.

  • Authenticate to Azure using the CLI:

     az login
    
  • Create a resource group (if you don't already have one):

     az group create --name myResourceGroup --location eastus
    
    • Deploy ARM template
   az deployment group create --resource-group myRG --template-file 
   template.json --parameters parameter.json

Fork Github Repo -
https://github.com/tracyee0/traycast1

Export Webapp to Azure

az webapp deployment source config --name ChineduOnyinye78 --resource-group myRG --repo-url https://github.com/tracyee0/traycast1 --branch master --manual-integration

Configure Your Web App
Navigate to the Azure Portal, go to your Web App's resource page, and configure settings such as custom domains, SSL certificates, or additional settings as needed.

Check Your Website
Open the URL of your web app in a browser. It should display your website as configured.https://chineduonyinye78.azurewebsites.net/

Conclusion
Deploying a website using Azure CLI and ARM templates streamlines the process, making it more manageable and repeatable. By following these steps, you’ve not only learned how to deploy a basic website but also gained a foundation for more complex deployments.

Feel free to expand upon this template based on your specific needs and resources. Azure’s flexibility and the power of ARM templates can handle a wide variety of deployment scenarios, so the sky’s the limit!

Happy deploying!


This content originally appeared on DEV Community and was authored by Tracy Chinedu


Print Share Comment Cite Upload Translate Updates
APA

Tracy Chinedu | Sciencx (2024-09-01T22:20:08+00:00) Deploy a Website using Azure CLI and ARM Template. Retrieved from https://www.scien.cx/2024/09/01/deploy-a-website-using-azure-cli-and-arm-template/

MLA
" » Deploy a Website using Azure CLI and ARM Template." Tracy Chinedu | Sciencx - Sunday September 1, 2024, https://www.scien.cx/2024/09/01/deploy-a-website-using-azure-cli-and-arm-template/
HARVARD
Tracy Chinedu | Sciencx Sunday September 1, 2024 » Deploy a Website using Azure CLI and ARM Template., viewed ,<https://www.scien.cx/2024/09/01/deploy-a-website-using-azure-cli-and-arm-template/>
VANCOUVER
Tracy Chinedu | Sciencx - » Deploy a Website using Azure CLI and ARM Template. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/09/01/deploy-a-website-using-azure-cli-and-arm-template/
CHICAGO
" » Deploy a Website using Azure CLI and ARM Template." Tracy Chinedu | Sciencx - Accessed . https://www.scien.cx/2024/09/01/deploy-a-website-using-azure-cli-and-arm-template/
IEEE
" » Deploy a Website using Azure CLI and ARM Template." Tracy Chinedu | Sciencx [Online]. Available: https://www.scien.cx/2024/09/01/deploy-a-website-using-azure-cli-and-arm-template/. [Accessed: ]
rf:citation
» Deploy a Website using Azure CLI and ARM Template | Tracy Chinedu | Sciencx | https://www.scien.cx/2024/09/01/deploy-a-website-using-azure-cli-and-arm-template/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.