Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Azure by (13.1k points)

I am not able to understand how to build/release pipelines setup for deploying application of NestJS to Azure DevOps. Herewith I attached my YAML :

trigger:

- master

pool:

  vmImage: 'ubuntu-latest'

steps:

- task: UseNode@1

  inputs:

    version: '14.x'

    checkLatest: true

- task: Npm@0

  displayName: Run NPM Update for NestJS

  inputs:

    cwd: '$(Build.SourcesDirectory)/ProjectName'

    command: update

- task: Npm@0

  displayName: Build NestJS

  inputs:

    cwd: '$(Build.SourcesDirectory)/ProjectName'

    command: run

    arguments: "build"

- task: CopyFiles@2

  inputs:

    Contents: 'dist/**'

    TargetFolder: '$(Build.ArtifactStagingDirectory)'

So, the problem is I am not able to see the "dist" folder in /home/site/wwwroot/ProjectName. Can anyone help me with this? What I am missing?

1 Answer

0 votes
by (26.7k points)

You have to use Azure App service Deploy task or Azure Web App task to deploy your app which is hosted in Azure. Now, to do that, firstly you need to create a service connection to Azure DevOps to connect your Azure Subscription. And after that, you need to add Azure App Service Deploy task/Azure Web App task at the end of your pipeline.

Prefer this example to understand it better.

- task: AzureRmWebAppDeployment@4

  inputs:

    ConnectionType: 'AzureRM'

    azureSubscription: 'SubscriptionServiceConnectionName'

    appType: 'webAppLinux'

    WebAppName: 'MyWebAppName'

    Package: '$(Build.ArtifactStagingDirectory)/dist/'

    StartupCommand: 'npm run start:prod'

I hope this will work.

Want to become an Azure DevOps expert? join azure devops certification now!!

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...