1
votes

I am trying to configure a CI/CD pipeline for our version 1.x Azure function. Azure function is triggered by Azure Service Bus and those configurations (topic and subscription) are in function.json file. We have few installations of this Azure function and want need to change function.json file somehow in Azure DevOps during build/release.

This is a "legacy work" so we don't have former CI/CD pipeline in Azure DevOps. Earlier this has been deployed manually from Visual Studio. I have now configured build and release configurations to Azure DevOps but they are not working as I expect: files are not deployed like before.

Working version is deployed like this:

wwwroot
 | - bin
 | | - dlls
 | | - de, es, fr, etc. folders
 | - MyFunction
 | | - function.json
 | - appsettings.json
 | - host.json
 | - packages.config
 | - Web.config

Now my attempt to deploy from Azure DevOps deploys it like this:

 wwwroot
 | - dlls
 | - host.json
 | - de, es, fr, etc. folders

It has only "bin folder" and function.json file is missing.

How should I build/deploy Azure function in Azure DevOps to deploy it like earlier with function.json file and bin folder? I have tried several different dotnet build and dotnet publish commands in build pipeline. In release pipeline I have used Azure App Service Deploy task to deploy.

2

2 Answers

1
votes

How should I build/deploy Azure function in Azure DevOps to deploy it like earlier with function.json file and bin folder?

I could deploy the Azure function correctly with Azure Devops CI/CD, the following is the detail steps:

1.The build task yaml file is as following:

queue:
  name: Hosted VS2017
  demands: 
  - msbuild
  - visualstudio

steps:
- task: NuGetToolInstaller@0
  displayName: 'Use NuGet 4.3.0'


- task: NuGetCommand@2
  displayName: 'NuGet restore'


- task: VSBuild@1
  displayName: 'Build solution **\*.sln'


- task: CopyFiles@2
  displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
  inputs:
    SourceFolder: 'FunctionApp2\bin\debug\net461'

    TargetFolder: '$(build.artifactstagingdirectory)'


- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'

The UI designer and project structs please refer to the screenshot.

enter image description here

2.Released task information: I use [Deploy Azure App Service] task and choose the App type: Function App. More information please refer to the screenshot

enter image description here

0
votes

Accidentally I solved this by myself. I run Visual Studio Build task with following parameters:

/p:DeployOnBuild=true
/p:WebPublishMethod=Package
/p:SkipInvalidConfigurations=true
/p:DesktopBuildPackageLocation="$(build.artifactstagingdirectory)/package/"
/p:DeployIisAppPath="Default Web Site"
/p:OutputPath="$(build.artifactstagingdirectory)/out/"

DesktopBuildPackageLocation builds it as I want to $(Build.ArtifactStagingDirectory)/package/WantedOutputPackage.zip. Then I publish that package as an artifact.