Install Node.js on a local device with recommended systems configuration and run Node.js app using Visual Studio Code by the following commands.
npm install
npm run
node filename.js
After running the node.js services, create a Azure app service for Node.js in azure portal.
.
Now lets create repository in Azure Devops and add a branch called develop and push all the application to that branch.
Add a file and and past the below code and save it with an extension .yml and click on commit.
[powershell]
# Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
trigger:
- main
- develop
pool:
vmImage: ubuntu-latest
steps:
- task: NodeTool@0
inputs:
versionSpec: '18.x'
displayName: 'Install Node.js'
- script: |
cd ./backend
npm install
# npm run build
displayName: 'npm install and build'
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)/backend'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
replaceExistingArchive: true
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
[/powershell]
Now lets start creating a Pipeline for the Node.js application.
Click on Pipelines and click on new pipeline. Select the current repository and add the existing YAML file and
run the pipeline.
Once pipeline creation is successful, lets create a release pipeline.
Create a release pipeline using the information’s from the Azure app service that you have created early and deploy the release pipeline.
The release pipeline that deploys the code tp the Azure app service.
The output for the code that is deployed to the Azure app service