来自天蓝色管道工件的自定义处理程序 defaultExecutablePath

custom handler defaultExecutablePath from azure pipeline artifacts

你好,我创建了一个 golang 自定义处理程序 azure 函数,我直接从 VS 代码部署了它,它运行得非常棒。

我想用 azure devops 管道添加一些 ci/cd,我设法构建了一个工件并将其发布在项目的已发布工件中,这里是 .yml 文件

trigger:
- main

pool:
  vmImage: ubuntu-latest

steps:

- task: GoTool@0
  inputs:
    version: '1.16'

- task: Go@0
  displayName: 'Build Application Binary'
  inputs:
    command: 'build'
    workingDirectory: '$(System.DefaultWorkingDirectory)/my-project/src/cmd/httpport'
    arguments: '-ldflags="-s -w" -o $(Build.BinariesDirectory)/bombastic'

- task: ArchiveFiles@2
  displayName: 'Archiving binaries ... '
  inputs:
    rootFolderOrFile: '$(Build.BinariesDirectory)'
    includeRootFolder: false
    archiveType: 'zip'
    archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
    replaceExistingArchive: true
  
- task: PublishBuildArtifacts@1
  displayName: 'publishing build artifacts'
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'
    replaceExistingArchive: true


我下载神器发布,解压,运行本地没问题

我使用工件创建了一个版本(Azure 管道中的功能版本),并且工件被推送到 azure 函数自定义处理程序。

我去查看 azure 函数应用程序文件,结构是 bombastic/bombastic bombastic 是函数的名称,/bombastic 是通常可以通过 ./bombastic.

调用的 linux 可执行文件

这是主机文件

{
  "version": "2.0",
  "logging": {
    "logLevel": {
      "default": "Trace"
    },
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true
      }
    }
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[1.*, 2.0.0)"
  },
  "customHandler": {
    "description": {
      "defaultExecutablePath": "bombasticv",
      "arguments": []
    },
    "enableForwardingHttpRequest": true
  }
}

当我点击函数 URL 时,我得到一个未找到的 404。

任何有关让 azure 函数自定义处理程序与 azure 管道工件一起工作的帮助都将不胜感激。

我想通了。我设置它的方式,它只压缩可执行文件,我做到了,所以 zip 文件夹包含 host.json 和函数文件夹并且它有效。