0

I'm getting an Azure DevOps CI/CD zip packaged deployment to Azure Function that successfully deploys code generally, but I'm having an issue with when I include an npm import (specifically Sequelize) that sees the app create the following error when trying to boot:

enter image description here

The details of the Azure Function configuration are detailed in this StackOverflow question:

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

Of the two examples of the imports failing, I've now only been able to get the functions to fail when importing a Sequelize class. Even then the results seem random (though I suspect there is some browser caching issues there).

Application Insights provides the following stack trace:

System.NullReferenceException:

   at Microsoft.Azure.WebJobs.Script.WorkerFunctionMetadataProvider+<GetFunctionMetadataAsync>d__10.MoveNext (Microsoft.Azure.WebJobs.Script, Version=4.23.0.0, Culture=neutral, PublicKeyToken=null: /_/src/WebJobs.Script/Host/WorkerFunctionMetadataProvider.cs:83)

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)

   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)

   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)

   at Microsoft.Azure.WebJobs.Script.WebHost.FunctionMetadataProvider+<GetFunctionMetadataAsync>d__10.MoveNext (Microsoft.Azure.WebJobs.Script, Version=4.23.0.0, Culture=neutral, PublicKeyToken=null: /_/src/WebJobs.Script/Host/FunctionMetadataProvider.cs:45)

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)

   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)

   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)

   at Microsoft.Azure.WebJobs.Script.FunctionMetadataManager.LoadFunctionMetadata (Microsoft.Azure.WebJobs.Script, Version=4.23.0.0, Culture=neutral, PublicKeyToken=null: /_/src/WebJobs.Script/Host/FunctionMetadataManager.cs:145)

   at Microsoft.Azure.WebJobs.Script.FunctionMetadataManager.GetFunctionMetadata (Microsoft.Azure.WebJobs.Script, Version=4.23.0.0, Culture=neutral, PublicKeyToken=null: /_/src/WebJobs.Script/Host/FunctionMetadataManager.cs:89)

   at Microsoft.Azure.WebJobs.Script.ScriptHost.GetFunctionsMetadata (Microsoft.Azure.WebJobs.Script, Version=4.23.0.0, Culture=neutral, PublicKeyToken=null: /_/src/WebJobs.Script/Host/ScriptHost.cs:372)

   at Microsoft.Azure.WebJobs.Script.ScriptHost+<InitializeAsync>d__93.MoveNext (Microsoft.Azure.WebJobs.Script, Version=4.23.0.0, Culture=neutral, PublicKeyToken=null: /_/src/WebJobs.Script/Host/ScriptHost.cs:279)

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)

   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)

   at System.Runtime.CompilerServices.TaskAwaiter.GetResult (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)

   at Microsoft.Azure.WebJobs.Script.ScriptHost+<StartAsyncCore>d__92.MoveNext (Microsoft.Azure.WebJobs.Script, Version=4.23.0.0, Culture=neutral, PublicKeyToken=null: /_/src/WebJobs.Script/Host/ScriptHost.cs:256)

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)

   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)

   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)

   at Microsoft.Extensions.Hosting.Internal.Host+<StartAsync>d__12.MoveNext (Microsoft.Extensions.Hosting, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)

   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)

   at System.Runtime.CompilerServices.TaskAwaiter.GetResult (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)

   at Microsoft.Azure.WebJobs.Script.WebHost.WebJobsScriptHostService+<UnsynchronizedStartHostAsync>d__52.MoveNext (Microsoft.Azure.WebJobs.Script.WebHost, Version=4.23.0.0, Culture=neutral, PublicKeyToken=null: /_/src/WebJobs.Script.WebHost/WebJobsScriptHostService.cs:328)

Given that I still have random reproducibility success, I'm shooting in the dark without having better insight into what variable/property is null.

How do I get that?

Aiden Dipple
  • 134
  • 2
  • 15

1 Answers1

0

Finally solved ... and not the answer that I was expecting!

To get detailed information on why the Functions App deployment fails … reach out to Microsoft Support by creating a ticket!

For me they were extremely helpful and supportive and I don’t think I would have solved it easily myself. The issue was made visible by the imports that I was including, mainly because the larger zipped file pushed the deployment package size over the threshold of where the issue was then occurring. Fewer and smaller NPM packages flew under then radar of this happening, but importing more or larger NPM packages and then the size reached the point where the issue was observed.

The cause:

In my Functions bicep file I was setting a configuration value (per one example / tutorial I found):

    {
      name: 'WEBSITE_RUN_FROM_PACKAGE'
      value: 1
    }

In my Azure DevOps yaml pipeline file, I was deploying the Function package with:

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

NOTE THE PARAMETER:

    deploymentMethod: 'zipDeploy'

This needed to change to:

    deploymentMethod: 'runFromPackage'

By incorrectly having the value set to 'zipDeploy' caused a conflict between the methods of deployment occurring. E.g: One saying ‘package deployment’ and the other saying ‘zip deployment’.

Similarly, the run from package option is more efficient by not unpacking all the zipped up nom packages.

There are two really cool efficiencies observed here with this setting:

  • The deployment pipeline task went from ~15 minutes to run down to 2 minutes
  • The function execution is now almost instant, where previously I thought I was seeing cold-start behaviour, or at least 10 seconds for function execution.

The team at Microsoft took the time to walk through my yaml and bicep, sit through a couple of deployments to see what was happening pinpointing the issue, and giving some great pointers on my stack and architecture design. Priceless!

Aiden Dipple
  • 134
  • 2
  • 15