Search code examples
azureazure-functionsazure-pipelinescicd

ci pipeline building an artifact for a function app contains no functions


I have a function app, I want to deploy functions into that function app

I made a CI and a CD pipeline in azure devops, all of it results in no functions in the function app

this is what my CI yaml looks like

trigger: none

pool:
  vmImage: 'windows-latest'

steps:
- task: DotNetCoreCLI@2
  inputs:
    command: 'build'
    projects: '*.csproj'
- task: DotNetCoreCLI@2
  inputs:
    command: publish
    arguments: '--configuration Release --output publish_output'
    projects: '*.csproj'
    publishWebProjects: false
    modifyOutputPath: false
    zipAfterPublish: false
- task: ArchiveFiles@2
  displayName: "Archive files"
  inputs:
    rootFolderOrFile: "$(System.DefaultWorkingDirectory)/publish_output"
    includeRootFolder: false
    archiveFile: "$(System.DefaultWorkingDirectory)/build$(Build.BuildId).zip"
- task: PublishPipelineArtifact@1
  inputs:
    targetPath: $(System.DefaultWorkingDirectory)/build$(Build.BuildId).zip
    artifactName: 'adofunc'

I believe the problem is the artifact. I have tried to download this artifact and deploy the zip using az functionapp deployment source config-zip -g <resource_group> -n <app_name> --src <zip_file_path> after setting SCM_DO_BUILD_DURING_DEPLOYMENT to true, also resulted in no functions

I manually set up another function app with functions in there, download the content from portal and compared the zip, they were very differernt

I have tried to use PublishBuildArtifacts@1 instead of PublishPipelineArtifact@1 in the pipeline, was no different, still the same old broken zip, and not having functions


Solution

  • Root Cause & Solution: The question is caused by your project itself. Following the official doc to create a new project resolves the issue.

    For any similar issue, you can build and deploy your function app locally to check whether it's caused by your project or the Azure pipeline.

    Official docs for your reference: