title: How to deploy multiple apps (monorepo) with Azure and NX
body: <p>I'm using <a href="http://nx.dev/" rel="noreferrer">NX</a> tools to manage a monorepo with multiple apps and I'm struggling to understand how to deploy using Azure and release pipelines.</p>
  
  <p><strong>Disclaimer</strong> : I'm very new to Azure and devops in general.</p>
  
  <p>My understanding is this :
  I create a pipeline (not a release pipeline, just a "regular one" if that make any sense) and plug a yml to it. Also, the pipeline is linked to a repo on Azure Repos, which means that every time I push to this repo, it will trigger the pipeline and run the yaml commands.
  On this commands, I run lint, test and builds.</p>
  
  <p>This is what I can do and can understand, <strong>the following become more obscure</strong> :</p>
  
  <p>The build job is supposed to create an artifact if I'm pusing/merging on master which I can conditioned.
  Now I can create a release pipeline which will be trigger when to repo it is linked to will create an artifact. This release pipeline can then send this artifact to an app service which is a slot where an app will live.</p>
  
  <p>Okay, but I'm using a monorepo, which means the build will produce multiple applications and each one of these apps should be deploy to the correct app service.</p>
  
  <p>After some research, <a href="https://github.com/nrwl/nx/issues/1930" rel="noreferrer">I found that</a> the general idea is to create one release pipeline for each app. These release pipelines are all linked to the same monorepo, but they have a filter which is a build tag. The build tag is added while building the apps using the yml file.</p>
  
  <p>So these are basically my understanding of all of this. Now here are the questions :</p>
  
  <ol>
  <li>What exactly is a build tag and where does it live? Is it somehow linked to an artifact?</li>
  <li>The idea is to create one build tag per artifact, right? </li>
  <li>I failed to create a build tag, how can I do so?</li>
  <li><p>What is the correct way to zip and publish the artifacts?</p>
  
  <p>Here is the yaml I'm using :</p></li>
  </ol>
  
  <pre><code>jobs:
    - job: Lint
      steps:
        - task: NodeTool@0
          inputs:
            versionSpec: '12.x'
          displayName: 'Install Node.js'
        - task: Npm@1
          displayName: 'Npm install'
        - pwsh: 'npm run nx affected -- --target=lint --parallel --base=origin/master --maxParallel=4'
          displayName: 'Running lint'
  
    - job: Test
      steps:
        - task: NodeTool@0
          inputs:
            versionSpec: '12.x'
          displayName: 'Install Node.js'
        - task: Npm@1
          displayName: 'npm install'
        - pwsh: 'npm run nx affected -- --target=test --parallel --code-coverage --base=origin/master --maxParallel=4'
          displayName: 'Running tests'
  
    - job: Build
      steps:
        - task: NodeTool@0
          inputs:
            versionSpec: '12.x'
          displayName: 'Install Node.js'
        - task: Npm@1
          displayName: 'npm install'
        - pwsh: 'npm run nx affected -- --target=build --parallel --base=origin/master --prod'
          displayName: 'Running build'
        - pwsh: |
            npm run nx affected:apps -- --base=HEAD~1  --head=HEAD | grep -E '( - )(\w|-|\d|_)+' | sed -E 's/ - /##vso[build.addbuildtag]/g'
          displayName: 'Adding build tags'
  </code></pre>
  
  <p>When running this, test, lint and builds are working, but I don't think it adds a build tag, here is the log :</p>
  
  <p><a href="https://i.stack.imgur.com/Iw7DV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Iw7DV.png" alt="enter image description here"></a></p>
  
  <p>It appears like nothing happens... How can I correctly add the tag and make the release pipeline to be triggered?</p>
  
  <p>I've also found this snippet to zip and publish the artifact, but I don't know if I can use that since in a monorepo we should - I think - create multiple artifacts.</p>
  
  <p>5) So the last question is : how can I create multiple artifacts and is it even the good thing to do?</p>
  
  <p>Many many thanks in advance for the help, I know this is a long boring post and helping a noob can be boring but I'm stuck with this for way to long...</p>