skip to Main Content

More specifically ‘how can I determine what is causing Azure Function App failing to show the list of deployed functions in Portal ’ (e.g.: which logs and how to interpret them)?

My testing indicate that it’s post-deploy/pre-execution as outlined below.

I thought the issue was caused when I import certain libraries and instantiate them in the function. I believed this because of tests I ran based on a few lines of code being commented out and then reinstated. However, the last deployment attempt had the functions displaying and working!

NOTE: As of today (7am AEST, vs last night 7pm AEST) it looks like the Azure Function App Portal "Overview" blade has been updated to list the functions (instead of on the "Functions" blade that no longer is there … could Microsoft have fixed something behind the scenes also that has changed platform resilience?? (See "Function" blade now missing in red box below -> The "Overview" blade now has a "Functions" tab)

enter image description here

The functions are deployed using Azure DevOps pipeline which all deploy successfully.

The stack for my project is:

  • Typescript transpiled to Javascript
  • Azure Functions 2.0

The Host.json’s extension bundle

  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[3.15.0, 4.0.0)"
  }

The Package.json

"@azure/functions": "^4.0.0-alpha.7",
"applicationinsights": "^2.7.0",
"typescript": "~5.1.3"

I appreciate viewers might want to recreate the issue but to do this I’ll need to strip down project and will take some effort. I’d like a first-take on if people have encountered this first being the question is about how to self-investigate logs.

There are numerous StackOverflow questions about this that all seem to have the root cause as:

There are 2 scenarios in my instance where the functions successfully install but fail to list in the portal (the logs seem to indicate "Max restarts reached":

  • When I try to add the Sequelize Model class from package reference
    • I’ve successfully included other Sequelize items as a const { Op } = require('@sequelize/core'); within methods.
    • I’ve successfully included other Sequelize objects as a import { Transaction, FindOptions } from 'sequelize'; in the class imports.
    • If I try import { Model, Transaction, FindOptions } from 'sequelize'; in the class imports the functions no longer list in the Azure Function portal.
  • When I try to add my own private NPM class package reference

NOTE: In both above examples the code works locally (verified with various context.log() outputs) when executed in Visual Studio Code with Azure Functions plugin.

NOTE 2: As per this morning, the second example works (per images below), but I have no confidence the issue is solved … just that this test instance worked and the issue is more random than thought.

When I deploy to Azure Functions to Azure cloud the deployment succeeds, the artefacts are visible in console (see wwwroot below), but the functions are not listed in the known functions.

I am certain the issue has something to do with these imports. When I comment them out the functions appear in the portal as would be expected, and they execute as would be expected. Despite the last test run working with the code NOT commented out, there was very strong correlation with when the imports are commented out.

Here is the Azure DevOps Pipeline yaml (FYI: The UNION of the siteConfig property was from a tutorial on how to enable the Function App to get KeyVault secrets dynamically when running … it all works and all App Configuration settings are present in the deployed Function):

NOTE: The actual pipeline has multiple stages that create service principals and managed identities, provisions the function app, a key vault and lots of other goodies. The previous step dependency is copied out and I can just run this step to do the build/deploy to recreate the issue. Those other steps are omitted for brevity and the fact this one step takes ~12 – ~16 minutes to execute.

- stage: DeployFx
  # dependsOn:
  # - AuthorizeFx
  jobs:
  - job: DeployFx
    steps:
    - task: NodeTool@0
      inputs:
        versionSpec: '18.x'
      displayName: 'Install Node.js'
    - script: |
        npm run setup-npm-pat
        npm install
      displayName: 'npm install'

    - script: |
        npm run build
      displayName: 'npm build'
          
    - task: ArchiveFiles@2
      displayName: 'Create project zip'
      inputs:
        azureSubscription: $(azureServiceConnection)
        rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
        includeRootFolder: false
        archiveType: 'zip'
        archiveFile: '$(Build.ArtifactStagingDirectory)/functionapp.zip'
        replaceExistingArchive: true
        
    - task: PublishPipelineArtifact@1
      displayName: 'Publish zip artifact'
      inputs:
        targetPath: '$(Build.ArtifactStagingDirectory)/functionapp.zip'
        publishLocation: 'pipeline'

    - task: AzureFunctionApp@1
      displayName: 'Deploy Function App'
      inputs:
        azureSubscription: $(azureServiceConnection)
        appType: 'functionapp'
        resourceGroupName: '$(resourceGroup)'
        appName: 'fxa-$(appTag)'
        package: '$(Build.ArtifactStagingDirectory)/functionapp.zip'
        deploymentMethod: 'zipDeploy'

Here are the application settings:

siteConfig: {
  appSettings: union([
    {
      name: 'AzureWebJobsStorage'
      value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storageAccount.listKeys().keys[0].value}'
    }
    {
      name: 'WEBSITE_CONTENTAZUREFILECONNECTIONSTRING'
      value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storageAccount.listKeys().keys[0].value}'
    }
    {
      name: 'WEBSITE_CONTENTSHARE'
      value: toLower(functionAppName)
    }
    {
      name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
      value: appInsightsInstrumentationKey
    }
    {
      name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
      value: 'InstrumentationKey=${appInsightsInstrumentationKey}'
    }
    {
      name: 'FUNCTIONS_WORKER_RUNTIME'
      value: functionRuntime
    }
    {
      name: 'FUNCTIONS_EXTENSION_VERSION'
      value: '~4'
    }
    {
      name: 'WEBSITE_NODE_DEFAULT_VERSION'
      value: '~16'
    }
    {
      name: 'WEBSITE_RUN_FROM_PACKAGE'
      value: '1'
    }
    { name: 'WEBSITE_WEBDEPLOY_USE_SCM'
      value: 'true'
    }
  ], appSettings)
}

Here is the image of the functions that show they do appear (on the new format "Overview" blade in the portal):

If you image this screen not showing Fuctions (despite successful deployment and with files in the wwwroot directory … that is the issue/problem)!

enter image description here

Here are the lines of code I’m testing:

enter image description here

Here are the lines of code commented out:

enter image description here

To recreate the issue I was just commenting and uncommenting the code as shown above. For a long time (50 – 100 test iterations) this correlated to the functions being shown, or now shown in the Azure Portal (and associated 404 errors when executed when not showing function list). As mentioned, the last test this morning and the uncommented code actually worked (thereby showing it seems to be platform and not code). To prove the code worked see context.log output in the red box.

enter image description here

Using the Azure Function app’s ‘Console’ blade in the portal I am able to list the directory structure under wwwroot and see that these files exist and have been unpacked and successfully deployed. I’m continuing to work on this and will add image of non-listed functions in portal scenario with proof the code is deployed in the wwwroot in "Console" blade.

Help me Obiwan you’re my only hope! How do I find logs that show post-deploy/pre-execution faults?

2

Answers


  1. Chosen as BEST ANSWER

    I found the answer (partially thanks to @DannielMann reminding me to look in App Insights), and partially because I wonder if the Application Insights UI/UX has been update by Microsoft today? ... I'm sure I looked there before and didn't see the same output that I'm getting now.

    Basically, In App Insights there is a "Failures" blade in the "Investigate" group. This is listing a whole heap of Null Reference Exceptions for WebJobs (see red rectangles below).

    enter image description here

    To the right of this screen (not shown above) is a total count of errors which is a hyperlink. This lists each of the errors (probably from logs as mentioned by RithwikBojja). The list looks like:

    enter image description here

    As mentioned in the question, the only output was in the Log Stream (see below) and only stated the Function App was restarting:

    enter image description here

    But now there is a decent error description in the Failures Investigation blade that gives something to investigate for real (see below):

    enter image description here

    Now to try and workout what's causing the NPE ... but at least now there's a lead.


  2. As of today (7am AEST, vs last night 7pm AEST) it looks like the Azure Function App Portal "Overview" blade has been updated to list the functions (instead of on the "Functions" blade that no longer is there … could Microsoft have fixed something behind the scenes also that has changed platform resilience?? (See "Function" blade now missing in red box below -> The "Overview" blade now has a "Functions" tab)

    Yes, In Functions section you will only find:

    • App files
    • App keys
    • Proxies

    enter image description here

    And yes, Azure Portal UI is changed a bit and now function are shown in Overview section and this should new normal:

    enter image description here

    How do I find Azure Function logs that show post-deploy/pre-execution faults?

    To find logs post deploy/ any other logs pre/post/middle:

    • In my Function App, Click on Monitoring section then on logs:

      traces

    enter image description here

    If you are looking for any log particularly, you can use below query:

    traces
    | where message contains "xxxxx"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search