簡體   English   中英

Azure QnA Bot 的 DevOps 管道

[英]Azure DevOps Pipeline for QnA Bot

我正在嘗試為此示例聊天機器人獲取構建和發布管道 -> https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/javascript_nodejs/49.qnamaker-all-features

我已經擁有所有基礎設施資源。 我計划稍后將其自動化。 但目前我只需要部署代碼。 我可以得到一些幫助嗎?

Azure 項目有代碼簽入的 Repo。

構建管道需要是什么樣子的?

  1. 我想我需要為軟件包安裝 npm
  2. 使用 az bot prepare-deploy --code-dir "." 生成 web.config。 --lang Javascript
  3. 生成一個 zip 文件。

發布管道需要是什么樣子的?

  1. 我想我需要運行 az webapp deployment source config-zip --resource-group "" --name "" --src "<zipfile_from_build>"

這是我已經走了多遠:

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '10.x'
  displayName: 'Install Node.js 10.x'

- script: |
    npm install
  displayName: 'Install all modules'

任何幫助表示贊賞!

提前致謝,傑克。

更新:這是我最后的 yaml

trigger:
- main

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '10.x'
  displayName: 'Install Node.js'

- script: |
     npm install
  displayName: 'npm install and build'

- task: ArchiveFiles@2
  inputs:
    rootFolderOrFile: '$(Build.SourcesDirectory)'
    includeRootFolder: false
    archiveType: 'zip'
    archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
    replaceExistingArchive: true

- task: AzureRmWebAppDeployment@4
  displayName: 'Azure App Service Deploy: myTestBot'
  inputs:
    ConnectedServiceName: 'Release-Service-Connection'  
    azureSubscription: 'subscriptionName'
    WebAppName: 'BotName'
    ResourceGroupName: 'rgName'
    packageForLinux: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
    WebConfigParameters: '-Handler iisnode -NodeStartFile index.js -appType node' 

無需使用 az bot 生成 web.config。 Azure 應用服務部署任務可以自動生成 web.config。 您可以查看以下示例。

trigger:
- main
pool:
  vmImage: 'ubuntu-latest'
steps:
- task: NodeTool@0
  inputs:
    versionSpec: '10.x'
  displayName: 'Install Node.js'

- script: |
     npm install
  displayName: 'npm install and build'

  #generate zip package using archivefile task.
- task: ArchiveFiles@2
  inputs:
    rootFolderOrFile: 'Build.SourcesDirectory'
    includeRootFolder: false
    archiveType: 'zip'
    archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
    replaceExistingArchive: true
  
  #publish artifacts to azure devops server to be used in Release pipeline.
- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'

請查看示例構建、測試和部署 JavaScript 和 Node.js 應用程序以了解更多信息。

在創建發布管道之前。 您需要創建一個azure 資源管理器服務連接,以將您的 Azure 訂閱連接到 Azure devops。 有關示例,請參見此線程

然后就可以創建release pipeline ,將上面build pipeline發布的artifacts添加為pipeline Artifacts資源。 並添加階段 在發布管道中使用Azure 應用服務部署任務。

您可以配置 Azure 應用服務部署任務以生成 web.config 另請參閱此處以獲取更多信息。

在此處輸入圖像描述

您還可以查看此博客中的示例。

實際上,您可以直接在構建管道中部署 Azure App Service,而無需創建發布管道。

- task: ArchiveFiles@2
  inputs:
    rootFolderOrFile: 'samples/javascript_nodejs/49.qnamaker-all-features'
    includeRootFolder: false
    archiveType: 'zip'
    archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
    replaceExistingArchive: true
  
- task: AzureRmWebAppDeployment@4
  displayName: 'Azure App Service Deploy: leviwebApp'
  inputs:
    azureSubscription: 'azure Resource Manager service connection'
    WebAppName: leviwebApp
    packageForLinux: '$(Build.ArtifactStagingDirectory)/**/*.zip'
    WebConfigParameters: '-Handler iisnode -NodeStartFile index.js -appType node'

以上使用構建/發布管道和部署任務的方法是部署到 azure 應用服務的一般方法。

但是,您也可以在構建管道中的 azure cli 任務中編寫 az cli commnads 以部署到 azure 應用服務。 請參閱以下示例:

 ....
- script: |
    cd samples/javascript_nodejs/49.qnamaker-all-features
    npm install
    
  displayName: 'npm install and build'

- task: AzureCLI@2
  inputs:
    azureSubscription: 'azure Resource Manager service connection'
    scriptType: 'bash'
    scriptLocation: 'inlineScript'
    inlineScript: 'az bot prepare-deploy --code-dir "." --lang Javascript'
   
- task: ArchiveFiles@2
  inputs:
    rootFolderOrFile: 'Build.SourcesDirectory'
    includeRootFolder: false
    archiveType: 'zip'
    archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
    replaceExistingArchive: true
- task: AzureCLI@2
  inputs:
    azureSubscription: 'azure Resource Manager service connection'
    scriptType: 'bash'
    scriptLocation: 'inlineScript'
    inlineScript: 'az webapp deployment source config-zip --resource-group "<resource-group-name>" --name "<name-of-web-app>" --src "<project-zip-path>"'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM