azure-functions-dotnet-worker: Azure Function not working with Microsoft.Azure.Functions.Worker.Sdk `1.17.3`/`1.17.4`

Description

Hi, my team is having trouble upgrading Microsoft.Azure.Functions.Worker.Sdk. Our application was running fine until we upgraded from version 1.17.2 to 1.17.4. We also tried 1.17.3 and experienced the same issue there. My colleague already created a discussion about the same issue in #2607.

Problem

Building the app works fine, as well as deploying to Azure using the AzureFunctionApp@2 step. Once deployed, all HTTP-triggered functions return a 404 Not Found (when including valid Authentication headers). We think this is because the Function App fails to “discover” the functions in our application (see screenshots below).

Application Insights logging (which we already had configured using SDK version 2.22.0) does not show any requests or exceptions after deploying the app, same for the Log Stream (because that uses AppInsights as well). Once we deploy again using 1.17.2 the logging is working again I also downloaded a Diagnostic dump via Kudu, but I didn’t find any relevant error there.

I will keep digging and update this issue if I find anything. If others are experiencing this, or if you are able to reproduce, please let me know! 😇

Screenshots

This shows the difference in the Azure Portal between 1.17.2 and 1.17.3:

Healthy deployment using 1.17.2
Unhealthy deployment using 1.17.3

Steps to reproduce

None of our Azure infrastructure changed, but for the purpose of reproducing the issue, here are the details of our setup.

  • Function project:

    • Target framework: net8.0
    • Functions version: v4
    • HTTP-triggered function
  • Function App configuration:

    • Region: West Europe
    • Pricing plan: Elastic Premium EP1
    • OS: Windows
    • Runtime version: 4.34.2.22820
    • Inbound traffic: public network access disabled, 1 private endpoint configured

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 31 (11 by maintainers)

Most upvoted comments

Same issue with 1.18.0, been using 1.17.2 on all my functions for quite a while now.

We’ve solved the original issue (I’m on @EdwinOtten 's team). The problem was in our manner of publishing, in particular the ArchiveFiles task. We had some custom publishing logic in place in our pipeline, probably to counter the fact that our build produces multiple artifacts, one of which beyond our control: WorkerExtensions.zip, not ours, but Microsoft.Azure.Functions.Worker.Extensions.

To fix the problem we refactored the publish step to use “zipAfterPublish: true”. We had “zipAfterPublish: false” before and did our own zipping. Also note we removed “modifyOutputPath: false”, defaulting to “modifyOutputPath: true”. It’s this last setting that caused the strange directory tree with the /bin/ folder in the zip.

Old:

steps:
  - task: DotNetCoreCLI@2
    inputs:
      command: publish
      publishWebProjects: false
      projects: |
        | 
        **/*.csproj 
        !**/*.Tests.csproj
      arguments: >-
        --configuration Release
        --output publish_output
      zipAfterPublish: false
      modifyOutputPath: false

  - task: ArchiveFiles@2
    displayName: Archive $(System.DefaultWorkingDirectory)/publish_output
    inputs:
      rootFolderOrFile: $(System.DefaultWorkingDirectory)/publish_output
      includeRootFolder: false
      archiveFile: $(System.DefaultWorkingDirectory)/build$(Build.BuildId).zip

  - task: PublishBuildArtifacts@1
    displayName: Publish Artifact drop
    inputs:
      PathtoPublish: $(System.DefaultWorkingDirectory)/build$(Build.BuildId).zip

New:

steps:
  - task: DotNetCoreCLI@2
    inputs:
      command: publish
      publishWebProjects: false
      projects: |
        | 
        **/*.csproj 
        !**/*.Tests.csproj
      arguments: >-
        --configuration Release
        --output $(Build.ArtifactStagingDirectory)
      zipAfterPublish: true
  - publish: $(Build.ArtifactStagingDirectory)
    artifact: drop

After doing this, in the actual deploy job the reference to the artifact package wasn’t valid anymore, because of the multiple available packages. That reference needed an update as well. The parameter projectName was introduced to select the right package, it’s value being the csproj filename (without the extension).

parameters:
  - name: serviceConnectionName
    type: string
  - name: environment
    type: string
  - name: appName
    type: string
  - name: environmentName
    type: string
  - name: agentPoolName
    type: string
  - name: projectName
    type: string

jobs:
  - deployment: Deploy_${{ parameters.environment }}
    displayName: Deploy_${{ parameters.environment }}
    environment: ${{ parameters.environmentName }}
    pool: ${{ parameters.agentPoolName }}
    strategy:
      runOnce:
        deploy:
          steps:
            - task: AzureFunctionApp@2
              displayName: Azure Function App Deploy
              inputs:
                azureSubscription: ${{ parameters.serviceConnectionName }}
                appType: functionApp
                appName: ${{ parameters.appName }}
                resourceGroupName: rg-sww-api-${{ parameters.environment }}
                package: $(Pipeline.Workspace)/drop/${{ parameters.projectName }}.zip
                deploymentMethod: runFromPackage

Just adding some info.

I’m also getting the 404 Not Found, after deployment via pipeline, as originally described by @EdwinOtten. Although my function app (pre-deployed via IaC) was originally set to .NET 8 isolated, after the Azure DevOps pipeline runs that gets reverted to .NET 6 in-process. If I force that back to .NET isolated the functions are then found. But it breaks again when I next deploy.

The closest clue I have indicating when that reversion will happen is the runtimeTarget in function.deps.json. When the build sets that to v6.0 the deployment breaks my function app as above. When it is rather set to v8.0, all is good. I’m presently failing to consistently get it to output v8 in the build, regardless of SDK version and even when passing “-f net8.0” argument . Busy trying to figure out what is causing the set of v6.

Bottom line, I cannot reliably deploy a function in .NET 8 isolated mode.

UPDATE

This reversion to net6 was caused by something else. In my IaC I failed to set the 8.0 isolated mode in my staging slot, so when my slot swap was done, the v6 staging slot was being swapped over the v8 function app…