title: How to work with DependsOn having stage dependency in Azure DevOps
body: <p>I have below template which does multi stage deployment:</p>
  <pre><code>parameters:
  - name: Stage
    type: string
  - name: Environment
    type: string
  - name: Enabled  
    type: boolean
    default: false
  - name: WebAppName
    type: string
  - name: ArtifactName
    type: string
  
  stages:
  
  - stage: ${{ parameters.Stage }}  
    displayName: '${{ parameters.Stage }} Stage'
    dependsOn: '${{ parameters.DependsOn }}'
    jobs:
     - deployment: ${{ parameters.Environment }} 
       timeoutInMinutes: 70
       environment: '${{ parameters.Environment }} Environment'
       pool:
          vmImage: $(vmImageName)
       strategy:
        runOnce:
          deploy:
            steps:
            - task: DownloadBuildArtifacts@0
              inputs:
                buildType: 'current'
                downloadType: 'single'
                artifactName: ${{ parameters.ArtifactName }}
                downloadPath: '$(System.ArtifactsDirectory)'
            - task: AzureRmWebAppDeployment@4
              inputs:
                ConnectionType: 'AzureRM'
                azureSubscription: 'AzureConnectionSC'
                appType: 'webApp'
                WebAppName: ${{ parameters.WebAppName }}
                package: '$(System.ArtifactsDirectory)/**/*.zip'
  </code></pre>
  <p>And from my pipeline I am using the template:</p>
  <pre><code>- template: azure-pipelines-multi-stage-release.yml  # Template reference
      parameters:
         Environment: 'Dev'
         Enabled: True
         WebAppName: 'azureappservicehelloworldapp-dev'
         Stage: 'Dev'
         ArtifactName : 'helloWorldArtifact'
  
    - template: azure-pipelines-multi-stage-release.yml  # Template reference
      parameters:
         Environment: 'UAT'
         Enabled: True
         WebAppName: 'azureappservicehelloworld-uat'
         Stage: 'UAT'
         ArtifactName : 'helloWorldArtifact'
  
    - template: azure-pipelines-multi-stage-release.yml  # Template reference
      parameters:
         Environment: 'Prod'
         Enabled: True
         WebAppName: 'azureappservicehelloworld'
         Stage: 'Prod'
         ArtifactName : 'helloWorldArtifact'
  </code></pre>
  <p>How do I pass DependsOn onto the template, in dev there is no stage dependency so it should deploy directly but UAT is dependent on Dev, Prod is Dependent on UAT. How can I pass value to template, if nothing is passed it should go on with deployment and if something is passed as dependency it should validate that stage before installing.</p>