0

I am trying to get a build and release pipeline for the this sample chatbot -> https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/javascript_nodejs/49.qnamaker-all-features

I already have all the infrastructure resources in place. I plan to automate this later. But the for the moment I just need to deploy the code. Can I get some help on this?

The Azure Project has the Repo with the code checked in.

What does the Build Pipeline need to look like?

  1. I think I need to do an npm install for packages
  2. generate the web.config using az bot prepare-deploy --code-dir "." --lang Javascript
  3. generate a zip file.

What does the Release Pipeline need to look like?

  1. I think I neeed to run az webapp deployment source config-zip --resource-group "" --name "" --src "<zipfile_from_build>"

This is how far I have gotten:

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'

Any help appreciated!

Thanks in advance, Jake.

UPDATE: Here is my final 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' 
JakeUT
  • 359
  • 1
  • 4
  • 16

1 Answers1

1

There is not need to generate the web.config using az bot. Azure App Service deploy task can generate the web.config automatic. You can check out below examples.

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'

Please check out the example Build, test, and deploy JavaScript and Node.js apps for more information.

Before creating Release pipeline. You need to create an azure Resource Manager service connection to connect your Azure subscription to Azure devops. See this thread for an example.

Then you can create release pipeline, Add the artifacts published by above build pipeline as the pipeline Artifacts resource. And add stages. Using Azure App Service deploy task in the release pipeline.

You can configure the Azure App Service deploy task to generate web.config. Also see here for more information.

enter image description here

You can also check out the example in this blog.

Actually you can directly use the Azure App Service deploy in the build pipeline without creating release pipeline.

- 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'

Above method using build/release pipeline and deployment task is the general way to deploy to azure app service.

However, you can also write az cli commnads in the azure cli task in the build pipeline to deploy to azure app service. See below example:

 ....
- 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>"'
Levi Lu-MSFT
  • 27,483
  • 2
  • 31
  • 43