Azure / functions-action

Enable GitHub developers to deploy to Azure Function Apps using GitHub Actions
MIT License
155 stars 76 forks source link

Flex consumption with dotnet fails #245

Open davidobrien1985 opened 2 months ago

davidobrien1985 commented 2 months ago

Attempting to deploy a dotnet8 app to a flex consumption Function App:

  publish-flex:
    runs-on: windows-latest
    needs: build
    steps:
    - name: 'Download Build Artifacts'
      uses: actions/download-artifact@v4
      with:
        name: app-build
        path: output

    - name: 'Publish Azure Flex Functions'
      uses: Azure/functions-action@v1.5.2
      with:
        app-name: ${{ env.AZURE_FUNCTIONAPP_FLEX_NAME }}
        package: output
        publish-profile: ${{ secrets.PUBLISH_PROFILE }}
        sku: flexconsumption
        remote-build: true
        enable-oryx-build: false
        scm-do-build-during-deployment: false

This is the GitHub Actions output:

Successfully parsed SCM credential from publish-profile format.
Using SCM credential for authentication, GitHub Action will not perform resource validation.
Warning: Neither AzureWebJobsStorage nor AzureWebJobsStorage__accountName exist in app settings (from Kudu SCM site with publish-profile credential). Please ensure one of them is configured as it is critical for function runtime. For more information, please visit the function app settings reference page: https://docs.microsoft.com/en-us/azure/azure-functions/functions-app-settings#azurewebjobsstorage
Successfully acquired app settings from function app (with SCM credential)!
Will archive output into D:\a\_temp\temp_web_package_65[20](https://github.com/argos-au/argos/actions/runs/10193129493/job/28198133521#step:3:21)085252805692.zip as function app content
Will use Kudu https://<scmsite>/api/publish to deploy since Flex consumption plan is detected.
Will use parameter remote-build: true
Package deployment using One Deploy initiated.
Starting deployment pipeline.
[ValidationStep] starting.
[AppSettingValidation] starting.
[DeploymentStorageValidation] starting.
Validation completed
[SourcePackageUriDownloadStep] starting.
Zip package is present at /tmp/zipdeploy/a32def0f-6667-49a7-8855-9658271bdd3c.zip
[ExtractZipStep] starting.
Cleaning files in /tmp/zipdeploy/extracted
Extracted zip package in /tmp/zipdeploy/extracted
[OryxBuildStep] starting.
Running oryx build command: oryx build /tmp/zipdeploy/extracted -o /home/site/wwwroot --platform dotnet
Error: Couldn't detect a version for the platform 'dotnet' in the repo.
Error: Couldn't detect a version for the platform 'dotnet' in the repo.\n/opt/Kudu/Scripts/starter.sh oryx build /tmp/zipdeploy/extracted -o /home/site/wwwroot --platform dotnet
Failed during oryx build due to Error: Couldn't detect a version for the platform 'dotnet' in the repo.\n/opt/Kudu/Scripts/starter.sh oryx build /tmp/zipdeploy/extracted -o /home/site/wwwroot --platform dotnet
Deployment failed with Error: Error: Couldn't detect a version for the platform 'dotnet' in the repo.\n/opt/Kudu/Scripts/starter.sh oryx build /tmp/zipdeploy/extracted -o /home/site/wwwroot --platform dotnet
Error: Failed to deploy web package to Function App.
Error: Execution Exception (state: PublishContent) (step: Invocation)
Error:   When request Azure resource at PublishContent, oneDeploy : Failed to use D:\a\_temp\temp_web_package_6520085[25](https://github.com/argos-au/argos/actions/runs/10193129493/job/28198133521#step:3:26)2805692.zip as OneDeploy content
Error:     Package deployment using ZIP Deploy failed. Refer logs for more details.
Error: Deployment Failed!

I'm confused about two things:

davidobrien1985 commented 2 months ago

Is this being looked at?

cc @patelchandni ?

patelchandni commented 2 months ago

@davidobrien1985 - You have passed remoteBuild: true parameter. Therefore, there is remote build performed using oryx. If you do not want remote build, then change that parameter to false.

davidobrien1985 commented 2 months ago

@patelchandni I'm confused. This is to deploy to a Flex Consumption plan. According to the readme on this repo that is exactly the config we should pass.

Parameters only supported for Flex Consumption plan:

sku: For function app on Flex Consumption plan, set this to flexconsumption. You can skip this parameter for function app on other plans. If using RBAC credentials, then by default, GitHub Action will resolve the value for this paramter. But if using publish-profile, then you must set this for function app on Flex Consumption plan.
remote-build: For function app on Flex Consumption plan, enable build action from Kudu when the package is deployed onto the function app by setting this to true. For function app on Flex Consumption plan, do not set scm-do-build-during-deployment and enable-oryx-build. By default, this is set to false.
davidobrien1985 commented 2 months ago

@patelchandni are you still monitoring this?

I tried again using the exact parameters that the readme on this repo says I should use, but set remote-build to false now:

- name: 'Publish Azure Flex Functions EU'
      uses: Azure/functions-action@v1.5.2
      with:
        app-name: ${{ env.AZURE_FUNCTIONAPP_FLEX_NAME_EU }}
        package: output
        publish-profile: ${{ secrets.PUBLISH_PROFILE_EU }}
        sku: flexconsumption
        remote-build: false

That indeed finally uploaded the zip file to the container configured on the Consumption Flex Function App, but the Function App only shows WarmUp Function, not our app. Why is that? Do we need to build the app differently? Does the output package need to look differently?

The same package works without any issues on regular Function Apps. (see below)

- name: 'Publish Azure Premium Functions EU'
      uses: Azure/functions-action@v1.5.2
      with:
        app-name: ${{ env.AZURE_FUNCTIONAPP_NAME_EU }}
        package: output
        publish-profile: ${{ secrets.PUBLISH_PROFILE_PREMIUM_EU }}
frasermclean commented 2 months ago

I am getting the same "WarmUp" function displaying after deploying using this action. This Action was previously working for me successfully when deploying to a Flex Consumption plan. In my context, I am using RBAC to deploy with an azure/login@v1 action.

If I deploy manually from my desktop using VSCode, all the correct functions are visible in the portal.

Here are my workflow job steps:

      # Download artifact
      - name: Download artifact
        id: download-artifact
        uses: actions/download-artifact@v4
        with:
          name: ${{ inputs.jobsArtifactName }}

      # Login to Azure
      - name: Login to Azure
        uses: azure/login@v1
        with:
          tenant-id: ${{ secrets.AZURE_TENANT_ID }}
          client-id: ${{ secrets.AZURE_CLIENT_ID }}
          subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

      # Publish application
      - name: Publish application
        uses: Azure/functions-action@v1
        with:
          app-name: ${{ needs.deploy_infra.outputs.functionAppName }}
          package: ${{ steps.download-artifact.outputs.download-path }}
davidobrien1985 commented 2 months ago

@frasermclean does that really deploy a Flex Consumption app? Looks like it's missing the sku parameter?

frasermclean commented 2 months ago

@frasermclean does that really deploy a Flex Consumption app? Looks like it's missing the sku parameter?

According to the docs, the action determines the correct SKU as I am using RBAC auth.

davidobrien1985 commented 2 months ago

@patelchandni any idea why this is happening? Now two people get the same incorrect outcome.

mangzee commented 1 month ago

Unfortunately, I have the same issue, I tried with remoteBuild: false and the deployment succeeded but I do not see the functions.

davidobrien1985 commented 1 month ago

@patelchandni or anybody else from Microsoft? Anybody watching this?

nzthiago commented 1 month ago

We are still investigating @davidobrien1985's app through a support case. We mitigated the issue to a certain degree by adding WEBSITE_USE_PLACEHOLDER_DOTNETISOLATED app setting and setting a value of 0. Unfortunately, it is not possible to tell if this is the same issue @mangzee, we would need a support ticket to be able to investigate your app as well, as the app is deploying but failing to show the functions.

mangzee commented 1 month ago

We are still investigating @davidobrien1985's app through a support case. We mitigated the issue to a certain degree by adding WEBSITE_USE_PLACEHOLDER_DOTNETISOLATED app setting and setting a value of 0. Unfortunately, it is not possible to tell if this is the same issue @mangzee, we would need a support ticket to be able to investigate your app as well, as the app is deploying but failing to show the functions.

@nzthiago @davidobrien1985 I'm sorry for not getting back to you sooner, but I could manage to get it to work. I'm not sure which of the below got it working, but these are steps performed

  1. Set WEBSITE_WEBDEPLOY_USE_SCM = false on the function env variables.
  2. And this was the YAML used in github actions
name: Deploy DotNet project to Azure Function App

on:
  push:
    branches: ["main"]

env:
  AZURE_FUNCTIONAPP_NAME: 'testfunc'   # set this to your function app name on Azure
  AZURE_FUNCTIONAPP_PACKAGE_PATH: 'Src/Functions/TestFunc'       # set this to the path to your function app project, defaults to the repository root
  DOTNET_VERSION: '8.0.x'                   # set this to the dotnet version to use (e.g. '2.1.x', '3.1.x', '5.0.x')

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    environment: dev
    steps:
    - name: 'Checkout GitHub Action'
      uses: actions/checkout@v4

    # If you want to use Azure RBAC instead of Publish Profile, then uncomment the task below
    # - name: 'Login via Azure CLI'
    #   uses: azure/login@v1
    #   with:
    #     creds: ${{ secrets.AZURE_RBAC_CREDENTIALS }} # set up AZURE_RBAC_CREDENTIALS secrets in your repository

    - name: Setup DotNet ${{ env.DOTNET_VERSION }} Environment
      uses: actions/setup-dotnet@v4
      with:
        dotnet-version: ${{ env.DOTNET_VERSION }}

    - name: 'Resolve Project Dependencies Using Dotnet'
      shell: bash
      run: |
        pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}'
        dotnet build --configuration Release --output ./output
        popd

    - 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 }}/output'
        publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }} # Remove publish-profile to use Azure RBAC
        sku: flexconsumption
        remote-build: false
bbevers2 commented 1 week ago

For dotnet packages, make sure that WEBSITE_RUN_FROM_PACKAGE does not exist in your Azure Environment variables for deployments with

        sku: flexconsumption
        remote-build: false

Otherwise, you may receive 404

David-M-Baxter commented 1 week ago

FYI, I've tried publish-profile without better success. Eventually i came to this:

Here's the output:

Using RBAC for authentication, GitHub Action will perform resource validation. Successfully acquired site configs from function app! Detected function app sku: Consumption Successfully acquired app settings from function app (RBAC)! Detected function app language: Node Will directly deploy ohana-server-1.10.0-build.1272.zip as function app content. Will use WEBSITE_RUN_FROM_PACKAGE to deploy since RBAC is detected and your function app is on Linux Consumption. Using AzureWebJobsStorage for Blob access. Package Url will use SAS. Sync Trigger call was successful.

davidobrien1985 commented 1 week ago

I get 404 deployment errors on basically every second deployment. I rerun the failed jobs, all good.

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: David Maugrion @.> Sent: Saturday, October 19, 2024 4:50:23 AM To: Azure/functions-action @.> Cc: David O'Brien @.>; Mention @.> Subject: Re: [Azure/functions-action] Flex consumption with dotnet fails (Issue #245)

FYI, I've tried publish-profile without better success. Eventually i came to this:

Here's the output:

Using RBAC for authentication, GitHub Action will perform resource validation. Successfully acquired site configs from function app! Detected function app sku: Consumption Successfully acquired app settings from function app (RBAC)! Detected function app language: Node Will directly deploy ohana-server-1.10.0-build.1272.zip as function app content. Will use WEBSITE_RUN_FROM_PACKAGE to deploy since RBAC is detected and your function app is on Linux Consumption. Using AzureWebJobsStorage for Blob access. Package Url will use SAS. Sync Trigger call was successful.

— Reply to this email directly, view it on GitHubhttps://github.com/Azure/functions-action/issues/245#issuecomment-2422961078, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACBIQGLYLZKMOEUENG7G4WDZ4FC57AVCNFSM6AAAAABLZ53EBCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMRSHE3DCMBXHA. You are receiving this because you were mentioned.Message ID: @.***>