Zip Deployment with az cli fails, but succeeds in Azure DevOps or Visual Studio

Joerg 1 Reputation point


i am not sure how to explain this behaviour properly and if the provided info is enough, but maybe you can at least give me a hint.

I have several Azure Functions that are currently deployed via Azure Devops. The Azure Devops pipeline uses the DotNetCoreCLI@2 task with command publish and zipAfterPublish set to true. Afterwards the artifact is made available via PublishBuildArtifacts@1. I then created a Release in Azure Devops, which makes use of the AzureFunctionApp@1 task to deploy those artifacts to the corresponding Azure Functions. This works perfectly fine.

For easier deployment to try out changes, I tried to build/publish the zipfiles locally and deploy via

az functionapp deployment source config-zip -g $resourceGroup -n $functionName --src $zipFile

To make sure the local dotnet publish step is not the reason for my error, I downloaded the artifacts from Azure Devops and deployed the exact files that were doing properly via Release Pipeline. However, this still does not work.

When deploying via the given CLI command, the deployment itself succeeds. When executing the function, I can see a null reference exception in my logs. This null reference exception is caused by a Refit instance, which is provided via Dependency Injection. I strongly suspect that the dependency injection is not working in this case.

Edit: Following the code, the instance/class which causes the NullReferenceException comes from another DLL. Other instances defined in myAzureFunction.dll seem to work.

Re-executing the release pipeline in Devops fixes this error.

There are several things I tried and investigated:

  • Applicationsettings are exactly the same and not changed during deployment steps (esp. WEBSITE_RUN_FROM_PACKAGE = 1 all the time). I verified this with Beyond Compare.
  • Restarting the app does not fix the issue
  • Deploying in Visual Studio via "Publish" and importing the Publishing profile makes the functions run properly
  • Using Runtime Version 4

Any ideas what might be the reason?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
3,986 questions
{count} votes