Developed one azure Devops yaml pipeline to publish my azure function in the azure function app, even it is running fine but still even after the push I cannot see my azure function gets deployed in Azure yaml pipeline. However I can see in the azure function app "deployment center" I can see my commit ids but under the overview tab nothings is there.
Below is the YAML pipeline:
trigger: none
pool:
name: test
stages:
- stage: deploy_function_app
jobs:
- deployment: FunctionAppDeployment
displayName: 'Function App Deployment'
environment: dev
strategy:
runOnce:
deploy:
steps:
- checkout: self
clean: true
- task: ArchiveFiles@2
displayName: 'Create project zip'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)/src'
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: 'connection'
appType: 'functionapp'
appName: 'myfunctionsharat'
package: '$(Build.ArtifactStagingDirectory)/functionapp.zip'
deploymentMethod: 'zipDeploy'
I have checked the Github Repo sample and reproduced the same issue.
You can refer to the following steps to modify your project and Pipeline:
For the Repo Project, you need to add the Function.json file to the path: src/functions
Function.json sample:
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "res"
}
],
"scriptFile": "../dist/src/functions/developerhttpfunction.js"
}
File path:
For the Azure DevOps Pipeline, you need to Build the TS project first, then you can deploy the generated package to Azure Function.
Here is an example:
stages:
- stage: Build
displayName: Build stage
jobs:
- job: Build
displayName: Build
pool:
name: test
steps:
- task: NodeTool@0
inputs:
versionSpec: '18.x'
displayName: 'Install Node.js'
- script: |
npm install
displayName: 'Prepare binaries'
- script: |
npm run build
displayName: 'Build Project'
- task: ArchiveFiles@2
displayName: 'Archive files'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
includeRootFolder: false
archiveType: zip
archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
replaceExistingArchive: true
- upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
artifact: drop
- stage: Deploy
displayName: Deploy stage
dependsOn: Build
condition: succeeded()
jobs:
- deployment: Deploy
displayName: Deploy
environment: test
pool:
name: test
strategy:
runOnce:
deploy:
steps:
- task: AzureFunctionApp@1
displayName: 'Azure Functions App Deploy: my-function-app-name'
inputs:
azureSubscription: 'xxx'
appType: 'functionApp'
appName: 'xxx'
package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'
deploymentMethod: 'auto'
Result:
Refer to this doc: Azure Functions triggers and bindings concepts