Shad Christopherson
Shad Christopherson

Reputation: 3

Cannot find dotnet version when deploying flex consumption function app with github actions

I am attempting to deploy a .Net 8 function app to a flex consumption plan on our Azure subscription. However, when I run the action, after the build, I get the error "Error: Couldn't detect a version for the platform 'dotnet' in the repo."

Github failure log

name: Deploy DotNet project to Azure Function App

on:
  push:
    branches: ["main"]

env:
  AZURE_FUNCTIONAPP_NAME: 'function app name'   
  AZURE_FUNCTIONAPP_PACKAGE_PATH: '.'       
  DOTNET_VERSION: '8.0.x'                   

jobs:
  build-and-deploy:
    runs-on: windows-latest # For Linux, use 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@v3
      with:
        dotnet-version: ${{ env.DOTNET_VERSION }}

    - name: 'Resolve Project Dependencies Using Dotnet'
      shell: pwsh
      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:
        sku: flexconsumption
        remote-build: true
        scm-do-build-during-deployment: false
        enable-oryx-build: false
        app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
        package: '${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}/output'

I have declared the dotnet version as a variable in the workflow file, and I have checked the solution and the .csproj file and they include the dotnet version as well.

Upvotes: 0

Views: 485

Answers (2)

Thiago Almeida
Thiago Almeida

Reputation: 166

Flex Consumption deployment is now supported in Visual Studio, VS Code, Azure Functions Core Tools, Azure Developer CLI (AZD), AZ CLI, GitHub Actions, Azure Pipelines task, and Java tooling like Maven.

Upvotes: 0

Ikhtesam Afrin
Ikhtesam Afrin

Reputation: 6497

  • Currently Flex Consumption plan is in Preview and under development phase and by looking at the MS Doc, I believe for now you can deploy the functions to Flex Consumption plan using either visual studio code or Core Tools.
  • I have created a workflow using the build in template present in GitHub Actions for Azure function app and added a secret AZURE_FUNCTIONAPP_PUBLISH_PROFILE in secrets and variables tab.
name: Deploy DotNet project to Azure Function App

on:
  push:
    branches: ["main"]

env:
  AZURE_FUNCTIONAPP_NAME: 'afreen-fa'   
  AZURE_FUNCTIONAPP_PACKAGE_PATH: '.'       
  DOTNET_VERSION: '8.0.x'                   

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

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

    - name: 'Resolve Project Dependencies Using Dotnet'
      shell: pwsh # For Linux, use 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 }}
  • Unfortunately, this code will fail with 404 error while deploying to Flex Consumption function app because a Flex Consumption app expects publish URI with the zip file to be scm_url + /api/publish whereas it is using scm_url + /api/zipdeploy.

enter image description here enter image description here

  • Product team is working on the fix which you can refer from this github issue.
  • I have deployed my function to Flex consumption function app successfully using visual studio code. So, I would suggest you to use Visual studio code or Core Tools for the time being.

enter image description here

enter image description here

Upvotes: 0

Related Questions