【问题标题】:how to deploy a custom dll along with azure function using appveyor如何使用 appveyor 部署自定义 dll 以及 azure 函数
【发布时间】:2017-03-09 20:13:22
【问题描述】:

如本文所述,使用 appveyor 部署 azure 函数非常简单 - https://alastairchristian.com/deploying-azure-functions-from-appveyor-75fe03771d0c#.x7stvprna

我无法弄清楚的是如何在 /bin 文件夹中部署自定义 dll(同一 repo 的库部分),以便能够使用 #r 并使用参考。

手动过程就是使用Kudu复制/bin文件夹中的dll并开始使用。

另请参阅关于 appveyor 的讨论 - http://help.appveyor.com/discussions/questions/2842-deployment-to-azure-function-app

这是我的 appveyor.yml -

    -
  branches:
    only:
      - master

  version: 0.0.{build}
  os: Visual Studio 2015
  configuration: Release
  init:
  - nuget sources update -Name nuget.org -Source https://api.nuget.org/v3/index.json
  environment:
    SolutionDir: $(APPVEYOR_BUILD_FOLDER)\
  cache:
  - packages -> **\packages.config
  assembly_info:
    patch: true
    file: '**\AssemblyInfo.*'
    assembly_version: '{version}'
    assembly_file_version: '{version}'
    assembly_informational_version: '{version}'
  before_build:
  - nuget restore -verbosity detailed

  build:
    verbosity: normal
    project: MyLibrary\MyLibrary.csproj
    publish_wap: true
    publish_azure: true
    parallel: true

  artifacts:
  - path: AzureFuncCIPOC
    name: AzureFuncCIPOC

  deploy:
  - provider: WebDeploy
    server: https://functioncipoc.scm.azurewebsites.net:443/msdeploy.axd?site=FunctionCIPOC
    website: FunctionCIPOC
    username: $FunctionCIPOC
    password:
      secure: <secure>
    artifact: AzureFuncCIPOC

【问题讨论】:

    标签: azure azure-functions appveyor


    【解决方案1】:

    如果您的构建过程正在构建该库并移动输出(您的自定义 DLL)以便打包在 AppVeyor 创建的工件中,它将与脚本一起部署。

    【讨论】:

    • 我不知道在这种情况下该怎么做
    • 有几种方法可以实现这一点,但是构建后操作/脚本(作为项目的一部分或在 AppVeyor 中)将您的 DLL 复制到 AzureFunctionCIPOC 文件夹中的适当位置应该给出你需要什么。
    • Fabio,根据我对 WebDeploy 的理解,您无权访问 bin 文件夹,对吧?我提出了一些解决方法here
    • 我正在尝试使用 7z 命令使其将 dll 放入工件中,但尚不知道如何使其进入存档中的 //bin 文件夹。我正在尝试的命令是这样的 - - 7z a AzureFuncCIPOC.zip .\AzureFuncCIPOC* - cd /D MyLibrary\ - 7z a AzureFuncCIPOC.zip bin\
    • 函数中的bin 文件夹有点不同,但是您应该可以将其打包。 @Abhishek 您可以尝试仅将该文件打包并部署以进行验证吗?
    【解决方案2】:

    我能够将所需的 dll 复制为项目构建后事件,然后使用与发布的问题相同的 .yml 来实现我所追求的目标。真心希望 VS 2017 在推出 VS2017 的 Azure Functions 工具时能对此有更好的支持。

    下面是构建后事件命令

    if not exist "$(SolutionDir)AzureFuncCIPOC\\ManualTriggerCSharp\bin\" mkdir "$(SolutionDir)AzureFuncCIPOC\\ManualTriggerCSharp\bin\"
    copy /y "$(TargetDir)" "$(SolutionDir)AzureFuncCIPOC\\ManualTriggerCSharp\bin\"
    

    【讨论】:

    • 这正是我在下面推荐的 :) 是的,我们工具的下一个版本将对这种情况提供更好的支持。
    • 期待!
    • 如果下面的答案有帮助,请将其标记为答案,以确保其他人也得到帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-31
    • 1970-01-01
    • 2012-03-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多