none
How to create zip file for Zip Deployment RRS feed

  • Question

  • Hello. Let's say I have a directory 'foo' that contains my Azure Function Project, built in TypeScript. My structure is like that described in the TypeScript documentation for Azure Function. I now want to create a zip file that I can publish to Azure using the Zip Deployment mechanism. How do I create the zip file manually? 

    EDIT: An explanation of how to create a local zip file on ones local development computer would be greatly appreciated. 

    • Edited by TeraInferno Friday, September 20, 2019 5:07 PM
    Thursday, September 19, 2019 8:48 PM

Answers

  • Hello @DixitArora-MSFT and @Jeremy_Brooks,

    I did take a look at the documentation provided. However, I still need to manually create the zip file locally. After some experimentation and reverse-engineering, I was able to come up with a solution:

    zip -r app.zip . --exclude @.funcignore --exclude .funcignore

    The above shell command works both in macOS as well as in Debian. I know have a local zip file I can deploy using the zip deploy system. I then used the Azure CLI to deploy it:

    az functionapp deployment source config-zip -g ${MY_RESOURCE_GROUP} -n ${MY_APP_NAME} --src app.zip
    Using this approach, I am able to avoid using the azure-function-core-tools all together. I have been finding that the azure-function-core-tools are somewhat flaky and also do not work well when used inside of a CI/CD pipeline. 
    • Proposed as answer by Jeremy_Brooks Wednesday, September 25, 2019 12:55 AM
    • Marked as answer by TeraInferno Wednesday, September 25, 2019 4:44 PM
    Tuesday, September 24, 2019 4:19 PM

All replies

  • 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.

    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

    function app For more information , follow the Download your function app files

    Friday, September 20, 2019 3:40 AM
    Moderator
  • Hi

    Please find the below Microsoft document reference link holds step-by-step process to perform Zip Download and Deployment in Azure Functions.

    https://docs.microsoft.com/en-us/azure/azure-functions/deployment-zip-push#download-your-function-app-files

    https://docs.microsoft.com/en-us/azure/azure-functions/deployment-zip-push#cli

    Hope this is helpful !!

    Thank you


    If this post helps to resolve your issue, please click the "Mark as Answer" of that post and/or click Answered "Vote as helpful" button of that post. By marking a post as Answered and/or Helpful, you help others find the answer faster.

    Friday, September 20, 2019 3:45 AM
  • Thanks for the response @DixitArora-MSFT. However, I was especially interested in creating a .zip file locally. Your answer and the documentation covers the REST API and Azure Portal method quite well. Unfortunately, I found the section of the documentation relating to local zip file creation to be lacking. It simply dismisses it as 'easy', but there is obviously more to it than just zipping the root project folder. For example, you might have to compile the TypeScript first or fetch npm dependencies. Could you expand your answer to include a more detailed explanation of what creating a zip file on your local development computer actually entails? Thanks. 
    Friday, September 20, 2019 5:05 PM
  • Have you seen this part of the documentation? I believe youll want to use the fucntion core tools to compile your function, then you can zip up the output or even use the core tools to deploy instead of running zip deploy manually. 

    https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-node#azure-functions-core-tools

    Saturday, September 21, 2019 2:10 AM
  • Just following up to check if you have gone through the documentation that Jeremy has pointed. 

    https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-node#azure-functions-core-tools

    Monday, September 23, 2019 3:23 AM
    Moderator
  • Hello @DixitArora-MSFT and @Jeremy_Brooks,

    I did take a look at the documentation provided. However, I still need to manually create the zip file locally. After some experimentation and reverse-engineering, I was able to come up with a solution:

    zip -r app.zip . --exclude @.funcignore --exclude .funcignore

    The above shell command works both in macOS as well as in Debian. I know have a local zip file I can deploy using the zip deploy system. I then used the Azure CLI to deploy it:

    az functionapp deployment source config-zip -g ${MY_RESOURCE_GROUP} -n ${MY_APP_NAME} --src app.zip
    Using this approach, I am able to avoid using the azure-function-core-tools all together. I have been finding that the azure-function-core-tools are somewhat flaky and also do not work well when used inside of a CI/CD pipeline. 
    • Proposed as answer by Jeremy_Brooks Wednesday, September 25, 2019 12:55 AM
    • Marked as answer by TeraInferno Wednesday, September 25, 2019 4:44 PM
    Tuesday, September 24, 2019 4:19 PM
  • Glad you found a solution! If you have time to report feedback on the core tools or any issues you've had you can create an issue on the core tools repository:

    https://github.com/Azure/azure-functions-core-tools/issues

    Wednesday, September 25, 2019 12:56 AM