简体   繁体   English

构建和发布 Azure 函数以包含 function.json 文件

[英]Build&release Azure function to include function.json file

I am trying to configure a CI/CD pipeline for our version 1.x Azure function.我正在尝试为我们的 1.x Azure 功能配置 CI/CD 管道。 Azure function is triggered by Azure Service Bus and those configurations (topic and subscription) are in function.json file. Azure 函数由 Azure 服务总线触发,这些配置(主题和订阅)在 function.json 文件中。 We have few installations of this Azure function and want need to change function.json file somehow in Azure DevOps during build/release.我们很少安装此 Azure 函数,并希望在构建/发布期间需要在 Azure DevOps 中以某种方式更改 function.json 文件。

This is a "legacy work" so we don't have former CI/CD pipeline in Azure DevOps.这是一项“遗留工作”,因此我们在 Azure DevOps 中没有以前的 CI/CD 管道。 Earlier this has been deployed manually from Visual Studio.早些时候,这是从 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.我现在已经为 Azure DevOps 配置了构建和发布配置,但它们没有像我预期的那样工作:文件没有像以前那样部署。

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:现在,我尝试从 Azure DevOps 进行部署是这样部署的:

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

It has only "bin folder" and function.json file is missing.它只有“bin 文件夹”并且缺少 function.json 文件。

How should I build/deploy Azure function in Azure DevOps to deploy it like earlier with function.json file and bin folder?我应该如何在 Azure DevOps 中构建/部署 Azure 函数以像之前一样使用 function.json 文件和 bin 文件夹部署它? I have tried several different dotnet build and dotnet publish commands in build pipeline.我在构建管道中尝试了几种不同的 dotnet build 和 dotnet publish 命令。 In release pipeline I have used Azure App Service Deploy task to deploy.在发布管道中,我使用 Azure 应用服务部署任务进行部署。

How should I build/deploy Azure function in Azure DevOps to deploy it like earlier with function.json file and bin folder?我应该如何在 Azure DevOps 中构建/部署 Azure 函数以像之前一样使用 function.json 文件和 bin 文件夹部署它?

I could deploy the Azure function correctly with Azure Devops CI/CD, the following is the detail steps:我可以使用 Azure Devops CI/CD 正确部署 Azure 功能,以下是详细步骤:

1.The build task yaml file is as following: 1.构建任务yaml文件如下:

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. UI 设计器和项目结构请参考截图。

在此处输入图片说明

2.Released task information: I use [Deploy Azure App Service] task and choose the App type: Function App. 2.发布任务信息:我使用【部署Azure应用服务】任务,选择App类型:Function App。 More information please refer to the screenshot更多信息请参考截图

在此处输入图片说明

Accidentally I solved this by myself.不小心我自己解决了这个问题。 I run Visual Studio Build task with following parameters:我使用以下参数运行 Visual Studio Build 任务:

/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 . DesktopBuildPackageLocation按照我想要的方式构建它$(Build.ArtifactStagingDirectory)/package/WantedOutputPackage.zip Then I publish that package as an artifact.然后我将该包作为工件发布。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure 函数构建未生成 function.json - Azure function build not generating function.json 从Azure DevOps发布管道部署Azure Function时如何修改function.json? - How to modify function.json when deploying Azure Function from Azure DevOps release pipeline? 自定义容器中的 Azure Function 和 TimerTrigger:在 function.D6D466DEEC76ECDF25 文件中还需要什么? - Azure Function & TimerTrigger in a Custom Container: what else do I need in the function.json file? 从 Azure Function 获取参数以用于 function.Z466DEEC76ECDF23456D38Zs 绑定71F6 - Getting parameters from an Azure Function to use in function.json bindings Azure函数部署失败,因为function.json错误 - Azure Function Deployment failing because function.json is wrong Java中的Azure函数使用function.json配置 - azure function in java configure using function.json Visual Studio Azure函数发布function.json - Visual Studio Azure Function Publishing function.json Azure function 缺少 function.Z466DEEC76ECDF324FCA6D385D74F 的本地绑定 - Azure function missing bindings in local for function.json Azure函数 - ICollector绑定不在结果function.json中 - Azure Functions - ICollector binding not in resulting function.json Azure Functions JavaScript function.json使用浮点数路由数据绑定 - Azure Functions JavaScript function.json route data binding with floats
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM