Deploy your app to Azure App Service with a ZIP or WAR file

This article shows you how to use a ZIP file or WAR file to deploy your web app to Azure App Service.

This ZIP file deployment uses the same Kudu service that powers continuous integration-based deployments. Kudu supports the following functionality for ZIP file deployment:

  • Deletion of files left over from a previous deployment.
  • Option to turn on the default build process, which includes package restore.
  • Deployment customization, including running deployment scripts.
  • Deployment logs.

For more information, see Kudu documentation.

The WAR file deployment deploys your WAR file to App Service to run your Java web app. See Deploy WAR file.

If you don't have an Azure subscription, create a free account before you begin.

Prerequisites

To complete the steps in this article:

Create a project ZIP file

Note

If you downloaded the files in a ZIP file, extract the files first. For example, if you downloaded a ZIP file from GitHub, you cannot deploy that file as-is. GitHub adds additional nested directories, which do not work with App Service.

In a local terminal window, navigate to the root directory of your app project.

This directory should contain the entry file to your web app, such as index.html, index.php, and app.js. It can also contain package management files like project.json, composer.json, package.json, bower.json, and requirements.txt.

Create a ZIP archive of everything in your project. The following command uses the default tool in your terminal:

# Bash
zip -r <file-name>.zip .

# PowerShell
Compress-Archive -Path * -DestinationPath <file-name>.zip

Deploy ZIP file

In the browser, navigate to https://<app_name>.scm.azurewebsites.net/ZipDeployUI.

Upload the ZIP file you created in Create a project ZIP file by dragging it to the file explorer area on the web page.

When deployment is in progress, an icon in the top right corner shows you the progress in percentage. The page also shows verbose messages for the operation below the explorer area. When it is finished, the last deployment message should say Deployment successful.

Deploy ZIP file with Azure CLI

Make sure your Azure CLI version is 2.0.21 or later. To see which version you have, run az --version command in your terminal window.

Deploy the uploaded ZIP file to your web app by using the az webapp deployment source config-zip command.

The following example deploys the ZIP file you uploaded. When using a local installation of Azure CLI, specify the path to your local ZIP file for --src.

az webapp deployment source config-zip --resource-group myResourceGroup --name <app_name> --src clouddrive/<filename>.zip

This command deploys the files and directories from the ZIP file to your default App Service application folder (\home\site\wwwroot) and restarts the app. If any additional custom build process is configured, it is run as well. For more information, see Kudu documentation.

Deploy ZIP file with REST APIs

You can use the deployment service REST APIs to deploy the .zip file to your app in Azure. To deploy, send a POST request to https://<app_name>.scm.azurewebsites.net/api/zipdeploy. The POST request must contain the .zip file in the message body. The deployment credentials for your app are provided in the request by using HTTP BASIC authentication. For more information, see the .zip push deployment reference.

For the HTTP BASIC authentication, you need your App Service deployment credentials. To see how to set your deployment credentials, see Set and reset user-level credentials.

With cURL

The following example uses the cURL tool to deploy a .zip file. Replace the placeholders <username>, <password>, <zip_file_path>, and <app_name>. When prompted by cURL, type in the password.

curl -X POST -u <deployment_user> --data-binary @"<zip_file_path>" https://<app_name>.scm.azurewebsites.net/api/zipdeploy

This request triggers push deployment from the uploaded .zip file. You can review the current and past deployments by using the https://<app_name>.scm.azurewebsites.net/api/deployments endpoint, as shown in the following cURL example. Again, replace <app_name> with the name of your app and <deployment_user> with the username of your deployment credentials.

curl -u <deployment_user> https://<app_name>.scm.azurewebsites.net/api/deployments

With PowerShell

The following example uses Invoke-RestMethod to send a request that contains the .zip file. Replace the placeholders <deployment_user>, <deployment_password>, <zip_file_path>, and <app_name>.

#PowerShell
$username = "<deployment_user>"
$password = "<deployment_password>"
$filePath = "<zip_file_path>"
$apiUrl = "https://<app_name>.scm.azurewebsites.net/api/zipdeploy"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))
$userAgent = "powershell/1.0"
Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -UserAgent $userAgent -Method POST -InFile $filePath -ContentType "multipart/form-data"

This request triggers push deployment from the uploaded .zip file. To review the current and past deployments, run the following commands. Again, replace the <app_name> placeholder.

$apiUrl = "https://<app_name>.scm.azurewebsites.net/api/deployments"
Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -UserAgent $userAgent -Method GET

Deploy WAR file

To deploy a WAR file to App Service, send a POST request to https://<app_name>.scm.azurewebsites.net/api/wardeploy. The POST request must contain the .war file in the message body. The deployment credentials for your app are provided in the request by using HTTP BASIC authentication.

For the HTTP BASIC authentication, you need your App Service deployment credentials. To see how to set your deployment credentials, see Set and reset user-level credentials.

With cURL

The following example uses the cURL tool to deploy a .war file. Replace the placeholders <username>, <war_file_path>, and <app_name>. When prompted by cURL, type in the password.

curl -X POST -u <username> --data-binary @"<war_file_path>" https://<app_name>.scm.azurewebsites.net/api/wardeploy

With PowerShell

The following example uses Invoke-RestMethod to send a request that contains the .war file. Replace the placeholders <deployment_user>, <deployment_password>, <zip_file_path>, and <app_name>.

$username = "<deployment_user>"
$password = "<deployment_password>"
$filePath = "<war_file_path>"
$apiUrl = "https://<app_name>.scm.azurewebsites.net/api/wardeploy"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))
Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Method POST -InFile $filePath -ContentType "multipart/form-data"

What happens to my app during deployment?

All the officially supported deployment methods have one thing in common: they make changes to the files in the /site/home/wwwroot folder of your app. These are the same files that are run in production. Therefore, the deployment can fail due to locked files, or the app in production may have unpredictable behavior during deployment because not all the files are updated simultaneously. There are a few different ways to avoid these issues:

Next steps

For more advanced deployment scenarios, try deploying to Azure with Git. Git-based deployment to Azure enables version control, package restore, MSBuild, and more.

More resources