37 C
Monday, July 22, 2024

Deploy Node.js to Azure App Service with Azure DevOps

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.

# 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

- main
- develop

  vmImage: ubuntu-latest

- task: NodeTool@0
    versionSpec: '18.x'
  displayName: 'Install Node.js'

- script: |
    cd ./backend
    npm install
   # npm run build
  displayName: 'npm install and build'

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

- task: PublishBuildArtifacts@1
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'



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

Santhosh M
Santhosh M
As a seasoned DevOps Engineer at Virtual Petals, I bring a wealth of expertise in Microsoft Cloud, DevOps, and the Microsoft 365 Stack. With a track record of delivering successful projects across the globe.

Related Articles


Please enter your comment!
Please enter your name here

× How can I help you?