Skip to content

Latest commit

 

History

History
99 lines (59 loc) · 6.63 KB

deployment-zip-push.md

File metadata and controls

99 lines (59 loc) · 6.63 KB
title description services documentationcenter author manager ms.service ms.devlang ms.topic ms.date ms.author
Zip push deployment for Azure Functions | Microsoft Docs
Use the .zip file deployment facilities of the Kudu deployment service to publish your Azure Functions.
functions
na
ggailey777
jeconnoc
azure-functions
multiple
conceptual
08/12/2018
glenga

Zip deployment for Azure Functions

This article describes how to deploy your function app project files to Azure from a .zip (compressed) file. You learn how to do a push deployment, both by using Azure CLI and by using the REST APIs. Azure Functions Core Tools also uses these deployment APIs when publishing a local project to Azure.

Azure Functions has the full range of continuous deployment and integration options that are provided by Azure App Service. For more information, see Continuous deployment for Azure Functions.

To speed development, you may find it easier to deploy your function app project files directly from a .zip file. The .zip deployment API takes the contents of a .zip file and extracts the contents into the wwwroot folder of your function app. This .zip file deployment uses the same Kudu service that powers continuous integration-based deployments, including:

  • Deletion of files that were left over from earlier deployments.
  • Deployment customization, including running deployment scripts.
  • Deployment logs.
  • Syncing function triggers in a Consumption plan function app.

For more information, see the .zip deployment reference.

Deployment .zip file requirements

The .zip file that you use for push deployment must contain all of the files needed to run your function.

Important

When you use .zip deployment, any files from an existing deployment that aren't found in the .zip file are deleted from your function app.

[!INCLUDE functions-folder-structure]

A function app includes all of the files and folders in the wwwroot directory. A .zip file deployment includes the contents of the wwwroot directory, but not the directory itself. When deploying a C# class library project, you must include the compiled library files and dependencies in a bin subfolder in your .zip package.

Download your function app files

When you are developing on a local computer, it's easy to create a .zip file of the function app project folder on your development computer.

However, you might have created your functions by using the editor in the Azure portal. You can download an existing function app project in one of these ways:

  • From the Azure portal:

    1. Sign in to the Azure portal, and then go to your function app.

    2. On the Overview tab, select Download app content. Select your download options, and then select Download.

      Download the function app project

    The downloaded .zip file is in the correct format to be republished to your function app by using .zip push deployment. The portal download can also add the files needed to open your function app directly in Visual Studio.

  • Using REST APIs:

    Use the following deployment GET API to download the files from your <function_app> project:

      https://<function_app>.scm.azurewebsites.net/api/zip/site/wwwroot/
    

    Including /site/wwwroot/ makes sure your zip file includes only the function app project files and not the entire site. If you are not already signed in to Azure, you will be asked to do so.

You can also download a .zip file from a GitHub repository. When you download a GitHub repository as a .zip file, GitHub adds an extra folder level for the branch. This extra folder level means that you can't deploy the .zip file directly as you downloaded it from GitHub. If you're using a GitHub repository to maintain your function app, you should use continuous integration to deploy your app.

Deploy by using Azure CLI

You can use Azure CLI to trigger a push deployment. Push deploy a .zip file to your function app by using the az functionapp deployment source config-zip command. To use this command, you must use Azure CLI version 2.0.21 or later. To see what Azure CLI version you are using, use the az --version command.

In the following command, replace the <zip_file_path> placeholder with the path to the location of your .zip file. Also, replace <app_name> with the unique name of your function app.

az functionapp deployment source config-zip  -g myResourceGroup -n \
<app_name> --src <zip_file_path>

This command deploys project files from the downloaded .zip file to your function app in Azure. It then restarts the app. To view the list of deployments for this function app, you must use the REST APIs.

When you're using Azure CLI on your local computer, <zip_file_path> is the path to the .zip file on your computer. You can also run Azure CLI in Azure Cloud Shell. When you use Cloud Shell, you must first upload your deployment .zip file to the Azure Files account that's associated with your Cloud Shell. In that case, <zip_file_path> is the storage location that your Cloud Shell account uses. For more information, see Persist files in Azure Cloud Shell.

[!INCLUDE app-service-deploy-zip-push-rest]

Run functions from the deployment package

You can also choose to run your functions directly from the deployment package file. This method skips the deployment step of copying files from the package to the wwwroot directory of your function app. Instead, the package file is mounted by the Functions runtime, and the contents of the wwwroot directory become read-only.

Zip deployment integrates with this feature, which you can enable by setting the function app setting WEBSITE_RUN_FROM_PACKAGE to a value of 1. For more information, see Run your functions from a deployment package file.

[!INCLUDE app-service-deploy-zip-push-custom]

Next steps

[!div class="nextstepaction"] Continuous deployment for Azure Functions