'Can't Get Output Variable into Deployment Job

I've been trying loads of combinations of this all day. I have a job that has a series of tasks and at the end I create two output variables that I want my deployment job to use. No matter what I do the echo contiainername line in the deployment job always returns a blank.

jobs:
- job: 'CreateAPMTemplates'
  displayName: 'Create APM templates'
  steps:
  - task: PowerShell@2
    inputs:
      targetType: inline
      script: (Invoke-WebRequest ifconfig.me/ip).Content.Trim()

  - task: AzureCLI@2
    displayName: 'Extract templates from Lab subscription'
    inputs:    
      azureSubscription: 'xxxxxxxx'
      scriptType: ps
      scriptLocation: inlineScript
      workingDirectory: 'xxxxxxxx'
      inlineScript: 'dotnet run extract --sourceApimName xxxxxx'
    
  - task: PublishBuildArtifacts@1
    displayName: 'Publish templates artifacts'
    condition: succeededOrFailed()
    inputs:  
      PathtoPublish: 'xxxxx'
      ArtifactName: 'templates'
      publishLocation: 'Container'

  - task: AzureFileCopy@3
    displayName: Copy deployment artifacts to the storage account
    inputs:
      sourcePath: 'xxxxxx'
      azureSubscription: 'xxxxxxx'
      destination: azureBlob
      storage: xxxxxx
      containerName: xxxxxx
      cleanTargetBeforeCopy: true
      outputStorageUri: al
      outputStorageContainerSasToken: alSasToken
      sasTokenTimeOutInMinutes: 30

  - powershell: echo "##vso[task.setvariable variable=outputContainerLocation; isOutput=true]$(al)"
    name: setContainerLocationVar

  - script: echo "$(outputContainerLocation)"
    name: echovar

  - powershell: echo "##vso[task.setvariable variable=outputSasToken; isOutput=true]$(alSasToken)"
    name: setSasTokenVar

  - script: echo "$(outputSasToken)"
    name: echovar2

- deployment: Deployment  
  displayName: 'Deploy APM templates'
  dependsOn: 'CreateAPMTemplates'
  condition: succeededOrFailed() 
  environment: 'dev'   
  variables:
    - name: containerLocation
      value: $[ dependencies.CreateAPMTemplates.outputs['setContainerLocationVar.outputContainerLocation'] ]
  strategy:
   runOnce:
    deploy:           
     steps:
      - script: echo "$(containerLocation)"
      - task: AzureResourceManagerTemplateDeployment@3
        displayName: 'Deploy APIM Products'
        inputs:    
          deploymentScope: 'Resource Group'
          azureResourceManagerConnection: 'yyyyyy'
          subscriptionId: 'yyyyyyy'
          action: 'Create Or Update Resource Group'
          resourceGroupName: 'yyyyyy'
          location: 'West Europe'
          templateLocation: 'Linked artifact'
          csmFile: 'yyyyyyyyyy'
          csmParametersFile: 'yyyyyyyyyy'
          deploymentMode: 'Incremental'
          overrideParameters: '-ApimServiceName yyyyyyyyyy -LinkedTemplatesBaseUrl $(al) -LinkedTemplatesSasToken $(alSasToken)'

Any ideas what i'm doing wrong? Within the deployment job I've tried the following permuations to get the output variable.

dependencies.CreateAPMTemplates.outputs['CreateAPMTemplates.setContainerLocationVar.outputContainerLocation'] ]

dependencies.CreateAPMTemplates.outputs['setContainerLocationVar.outputContainerLocation'] ]

dependencies.CreateAPMTemplates.outputs['outputContainerLocation'] ]



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source