Problem


Azure App Service offers a variety of deployment options tailored to the diverse needs of developers. These include integration with Git repositories, Azure DevOps, and direct deployment from IDEs like Visual Studio or Visual Studio Code.

But what if your project is a straightforward task that doesn't warrant the complexity of setting up an entire suite of tools or a continuous integration/continuous deployment (CI/CD) pipeline? Imagine you have a static website ready to go, sitting in a local folder—it's not part of a Git repository, and you don't have Visual Studio or Visual Studio Code at your disposal. Is there a straightforward way to deploy this website to Azure App Service without the usual overhead? Absolutely, and I'm going to walk you through a streamlined approach that minimizes effort to make your deployment ready in couple of minutes.

Solution


Install Azure CLI

If you haven't already, install the Azure CLI on your machine. You can download it from the official Azure CLI source.

Sign in to Azure

Run the following command to sign in to Azure.  This will open a browser window asking you to log in with your Azure credentials.

az login

If you have multiple Azure subscription, you need to choose one of them. Example:

az account set --subscription "DevTest"

Zip your website files

Before deploying, make sure all your website files (HTML, CSS, JavaScript, images, etc.) are in a folder. Then, create a zip file of this folder.

Please note, files must be in the root directory, in this example, the root of demo.zip should contain index.html, DO NOT wrap a folder outside of your website content files like demo/index.html

Set the deployment user

If you haven't set a deployment user for Azure Web Apps, you'll need to create one. This user is not the same as your Azure account user. It's a user specifically for deployment purposes.

az webapp deployment user set --user-name <username> --password <password>

Replace <username> and <password> with your own value.

Deploy your website

Use the az webapp deployment source config-zip command to deploy the zip file to your Azure App Service. You'll need to know the name of your App Service and the resource group it belongs to.

az webapp deployment source config-zip --resource-group <resource-group-name> --name <app-service-name> --src demo.zip

Replace <resource-group-name> with the name of your Azure resource group and <app-service-name> with the name of your Azure App Service.

After running this command, Azure will deploy the contents of your zip file to the App Service. You can then navigate to your App Service URL to see your static website live.