Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No documented way to deploy to consumption based linux functions (e.g. Python) #218

Open
mxmo0rhuhn opened this issue Mar 4, 2024 · 2 comments

Comments

@mxmo0rhuhn
Copy link

By now I spend several days trying to figure out how to deploy a Python function to a consumption based plan using this action and I have come to the conclusion that this is not possible. However, there is no warning or any indication about this. Please add either a documentation how to do it or a warning that it is not possible.

Setup

Python is supported only on a Linux-based hosting plan when it's running in Azure.

source

Function App

  • Operating System:Linux
  • App Service Plan Pricing plan: Y1 (consumption based)
  • Runtime version: 4.28.4.4
  • FUNCTIONS_WORKER_RUNTIME: python
  • FUNCTIONS_EXTENSION_VERSION: ~4

Action configuration

      - name: 'Run Azure Functions Action'
        uses: Azure/functions-action@v1
        id: fa
        with:
          app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
          slot-name: ${{ env.AZURE_FUNCTIONAPP_SLOT }}
          package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
          publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }}
          respect-funcignore: true
          scm-do-build-during-deployment: true
          enable-oryx-build: true

The action is exactly in line with the example. The slot-name has been added or removed but is irrelevant for the behaviour.

Repository structure

The repository contains a Hello world application using exactly the setup of the official documentation

Behaviour

In essence the problem boils down to the possible states of the WEBSITE_RUN_FROM_PACKAGE environment variable in the Azure Function.

Without WEBSITE_RUN_FROM_PACKAGE

A newly created Azure Function does not have the environment variable set. Therefore, the execution of the azure function fails.

Error: Failed to deploy web package to App Service.
Error: Execution Exception (state: PublishContent) (step: Invocation)
Error:   When request Azure resource at PublishContent, zipDeploy : Failed to use /home/runner/work/_temp/temp_web_package_26238559607[44](XXXX)894.zip as ZipDeploy content
Error:     Package deployment using ZIP Deploy failed. Refer logs for more details.
Error: Deployment Failed!

Btw. there is no indication where to find the logs that the error message is referring to in case of the failure. The link to the xxx.scm.azurewebsites.net logs is only displayed in case of a successful deployment .

With WEBSITE_RUN_FROM_PACKAGE = 1

In this case the GitHub action runs through without an error. However, the deployed function is not visible in the Azure Portal. This is somewhat expected behaviour as the documentation clearly states that Linux Consumption based Functions need to set the value to a URL:

External package URL is the only supported deployment method for Azure Functions running on Linux in the Consumption plan
Source
Other source

With WEBSITE_RUN_FROM_PACKAGE =

The expected solution is to set the WEBSITE_RUN_FROM_PACKAGE to a URL that is created during the deployment of the function using this GitHub Action e.g. the value of the SCM_RUN_FROM_PACKAGE variable. However, in this scenario the GitHub Action also fails:

Error: Execution Exception (state: PublishContent) (step: Invocation)
Error:   When request Azure resource at PublishContent, zipDepoy : WEBSITE_RUN_FROM_PACKAGE in your function app is set to an URL. Please remove WEBSITE_RUN_FROM_PACKAGE app setting from your function app.
Error: Deployment Failed!

The suggested fix to remove the variable does unfortunately not work as stated above.

With WEBSITE_RUN_FROM_PACKAGE = anything else

For the sake of completeness I also tried to run the action with something else than the official options. As expected, the function fails with:

Error: Failed to deploy web package to App Service.
Error: Execution Exception (state: PublishContent) (step: Invocation)
Error:   When request Azure resource at PublishContent, zipDeploy : Failed to use /home/runner/work/_temp/temp_web_package_5530634294070984.zip as ZipDeploy content
Error:     Package deployment using ZIP Deploy failed. Refer logs for more details.
Error: Deployment Failed!

Conclusion

Given that none of the options results in a working Azure function I have to assume that it is just not possible to use this action for consumption based Linux functions. I would be more than happy if you could highlight my mistake.

@patelchandni
Copy link
Collaborator

  1. WEBSITE_RUN_FROM_PACKAGE = 1 is not support of Linux app on Consumption plan. Documented here: https://learn.microsoft.com/en-us/azure/azure-functions/run-functions-from-deployment-package
  2. WEBSITE_RUN_FROM_PACKAGE = URL will only work with this action if you are using service principle and not publish profile. Also, it will not support remote build.
  3. If you want remote build, then used publish profile and pass remote build parameters with this action. Also, remove WEBSITE_RUN_FROM_PACKAGE app setting from your app.

@mxmo0rhuhn
Copy link
Author

Dear @patelchandni thanks a lot for summarizing the behaviour of WEBSITE_RUN_FROM_PACKAGE again.

Could you provide a working example of how to deploy a consumption based linux function with this action?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants