Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using AzureFileCopy task outputs in Azure-Pipelines.yml

I am trying to output outputStorageUri and outputStorageContainerSasToken from the AzureFileCopy task and consume them in a powershell script, a simple example of what I am trying to achieve is:

pool:
  vmImage: 'VS2017-Win2016'

variables:
  Parameters.outputStorageUri: ''
  Parameters.outputStorageContainerSasToken: ''

steps:

- task: AzureFileCopy@3
  inputs:
    sourcePath: '$(Build.ArtifactStagingDirectory)\MyProgram.ext'
    azureSubscription: 'MyAzureServiceRole'
    Destination: 'AzureBlob'
    storage: 'myfilestorage'
    ContainerName: 'programs'
    outputStorageUri: '$(Parameters.outputStorageUri)'
    outputStorageContainerSasToken: '$(Parameters.outputStorageContainerSasToken)'
    sasTokenTimeOutInMinutes: 5
  displayName: Upload program to Blob storage


- task: PowerShell@2
  inputs:
      targetType: 'inline'
      script: |
          Write-Host 'URL = ' + $Env:PARAMETERS_OUTPUTSTORAGEURI
      errorActionPreference: 'stop'
      failOnStderr: 'false'
  displayName: Send storage URL to Logger(s)

The file is copied correctly, however Write-Host in the example for the outputStorageUri is always blank! I have also tried a number of other ways to no avail... Please can someone enlighten me as to what I am doing wrong...

like image 887
Robin Avatar asked Jan 20 '26 22:01

Robin


2 Answers

We should use the name of the variable, not the variable value in the task.

Please change the $(Parameters.outputStorageUri) to Parameters.outputStorageUri $(Parameters.outputStorageContainerSasToken) to Parameters.outputStorageContainerSasToken, then it will work.

outputStorageUri: Parameters.outputStorageUri
outputStorageContainerSasToken: Parameters.outputStorageContainerSasToken

enter image description here

For more information please refer to Azure File Copy

provide the name of the output variable you would like to use.

like image 74
Tom Sun - MSFT Avatar answered Jan 22 '26 13:01

Tom Sun - MSFT


Kind of related but if you are using V4 then these are available as Output Variables. This is not there in the documentation but highlighted in this issue.

https://github.com/microsoft/azure-pipelines-tasks/issues/13246

like image 29
json singh Avatar answered Jan 22 '26 12:01

json singh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!