最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Successful Github Actions workflow does not deploy Python App to Azure Function - Stack Overflow

programmeradmin2浏览0评论

I am basically using the standard template for "Deploy Python app to Azure Functions App". Azure Function plan is Flex Consumption.

Here is the code snippet for deploying the python app:

- name: 'Run Azure Functions Action'
  uses: Azure/functions-action@v1
  id: fa
  with:
    app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
    package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
    sku: 'flexconsumption'    # Parameter required when using a publish profile with Flex Consumption
    publish-profile: ${{ secrets.AZURE_CREDENTIALS }} # Remove publish-profile to use Azure RBAC

The job ends successful with:

Package deployment using One Deploy initiated. Deploy logs can be viewed at Successfully deployed web package to Function App.

However afterwards the function list in Azure is empty:

The deployment is initiated, since previous functions deployed through VSC are deleted.

Deployment logs within Azure are not available:

"message": "The logs you are looking for were not found. In consumption plans, the instance will be recycled and logs will not be persisted after that. If you want them to be persisted ensure that Application Insights is enabled. See the Deployment Logs section here for more info: ;.

In Application Insights I cannot find any logs and to access Deployment Center->Logs in Azure portal I would first need to authenticate with Github.

Edit: I tested authenticating in Deployment Center. Using both Azure's auto-generated workflow and mine results in no errors, however in both cases, the function does not appear in the list of the function app. The logs in Deployment Center show that it worked:

Status: success (active)
"message": "Finished deployment pipeline.",
"message": "FunctionHostSyncTrigger, statusCode = OK",
"message": "Performed sync triggers successfully.",

Do you have any idea?

I am basically using the standard template for "Deploy Python app to Azure Functions App". Azure Function plan is Flex Consumption.

Here is the code snippet for deploying the python app:

- name: 'Run Azure Functions Action'
  uses: Azure/functions-action@v1
  id: fa
  with:
    app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
    package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
    sku: 'flexconsumption'    # Parameter required when using a publish profile with Flex Consumption
    publish-profile: ${{ secrets.AZURE_CREDENTIALS }} # Remove publish-profile to use Azure RBAC

The job ends successful with:

Package deployment using One Deploy initiated. Deploy logs can be viewed at https://xxx.scm.azurewebsites/api/deployments/xxx/log Successfully deployed web package to Function App.

However afterwards the function list in Azure is empty:

The deployment is initiated, since previous functions deployed through VSC are deleted.

Deployment logs within Azure are not available:

"message": "The logs you are looking for were not found. In consumption plans, the instance will be recycled and logs will not be persisted after that. If you want them to be persisted ensure that Application Insights is enabled. See the Deployment Logs section here for more info: https://aka.ms/flex-deployments".

In Application Insights I cannot find any logs and to access Deployment Center->Logs in Azure portal I would first need to authenticate with Github.

Edit: I tested authenticating in Deployment Center. Using both Azure's auto-generated workflow and mine results in no errors, however in both cases, the function does not appear in the list of the function app. The logs in Deployment Center show that it worked:

Status: success (active)
"message": "Finished deployment pipeline.",
"message": "FunctionHostSyncTrigger, statusCode = OK",
"message": "Performed sync triggers successfully.",

Do you have any idea?

Share Improve this question edited Mar 16 at 18:22 ray asked Mar 16 at 18:04 rayray 1711 gold badge4 silver badges21 bronze badges 2
  • Did you try deploying the same app using VS Code or CLI? – Pravallika KV Commented Mar 17 at 8:12
  • 1 In VSC it works perfectly fine. See answer from Saad. MSFT support resolved the issue :) – ray Commented Mar 17 at 9:57
Add a comment  | 

2 Answers 2

Reset to default 1

Sharing our findings here also to help the community.

The issue occurs because the GitHub Actions workflow does not include a prebuild step, and remote build is not enabled.

When deploying Python apps to Azure Functions with Flex Consumption, you must either:

  1. Prebuild the dependencies in your GitHub Actions pipeline before deployment, or

  2. Enable remote build, allowing Azure to handle the build process.

Solution 1: Prebuild in GitHub Actions

If you want to handle the build process in your pipeline, ensure that dependencies are installed and included in the deployment package:

- name: Create and start virtual environment
  run: |
    python -m venv venv
    source venv/bin/activate

- name: Install dependencies
  run: pip install -r requirements.txt -t .

This ensures that all dependencies are packaged before deployment.

Solution 2: Enable Remote Build

If you are not prebuilding dependencies in the pipeline, enable remote build in the deployment step:

- name: 'Deploy to Azure Functions'
  uses: Azure/functions-action@v1
  with:
    app-name: 'fncapp-fetchgitdata-dev'
    package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
    remote-build: true

This allows Azure to install dependencies during deployment.

Reference:

GitHub Actions for Azure Functions - Parameters

After applying either of these solutions, redeploy your function, and it should appear correctly in the Azure portal.

Hope this helps!

发布评论

评论列表(0)

  1. 暂无评论