英文:
Deploy azure function with GoLang
问题
目前我正在构建一个使用GoLang编写的Azure无服务器函数。我使用以下构建流程:
trigger:
- main
pool:
vmImage: 'vs2017-win2016'
steps:
- task: GoTool@0
inputs:
version: '1.16.2'
- task: Go@0
displayName: 'go get'
inputs:
arguments: '-d'
workingDirectory: '$(System.DefaultWorkingDirectory)'
- task: Go@0
displayName: 'go build'
inputs:
command: build
arguments: '-o go_ibors_backend main.go'
workingDirectory: '$(System.DefaultWorkingDirectory)'
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(Build.BinariesDirectory)'
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
构建流程已成功运行。此外,发布流程也成功部署,但是当我在Azure门户中查看我的函数时,没有结果显示。当我将函数本地推送到Azure时,所有的函数都会显示出来。
我做错了什么?
英文:
Currently I'm building a GoLang serverless Azure Function.
I use this build pipeline:
trigger:
- main
pool:
vmImage: 'vs2017-win2016'
steps:
- task: GoTool@0
inputs:
version: '1.16.2'
- task: Go@0
displayName: 'go get'
inputs:
arguments: '-d'
workingDirectory: '$(System.DefaultWorkingDirectory)'
- task: Go@0
displayName: 'go build'
inputs:
command: build
arguments: '-o go_ibors_backend main.go'
workingDirectory: '$(System.DefaultWorkingDirectory)'
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(Build.BinariesDirectory)'
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
The build pipeline has run successfully. Also, the release pipeline is deploying successful, but when I look at my functions in the Azure Portal there are no results. When I push the function locally to Azure then all my functions are displayed.
What I'm doing wrong?
答案1
得分: 0
问题在于ArchiveFiles指向了错误的rootFolderOrFile,并且includeRootFolder必须设置为false,因为作业将在根文件夹中查找host.json文件。
- task: ArchiveFiles@2
displayName: '创建构件'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
replaceExistingArchive: true
英文:
The problem was that ArchiveFiles was directing to the wrong rootFolderOrFile and that the includeRootFolder must be put to false, because the job will look for a host.json file in the root folder.
- task: ArchiveFiles@2
displayName: 'Create artifact'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
replaceExistingArchive: true
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论