Share via

Azure DevOps Blobcopy

Singh, Gaurav 5 Reputation points
2023-05-19T11:22:52.8133333+00:00

Hello Team,

I have tested the script in last three lines it works fine with the Azure powershell , when executed with a storage key

when executed in the pipeline, I am getting an error

##[error]Upload to container: 'testcontainer' in storage account: 'XXXXXXXXXtest' with blob prefix: '' failed with error: 'AzCopy.exe exited with non-zero exit code while uploading files to blob storage.' For more info please refer to https://aka.ms/azurefilecopyreadme



I have tested the script in last three lines it works fine with the Azure powershell , when executed with a storage key

when executed in the pipeline

I am getting an error

##[error]Upload to container: 'testcontainer' in storage account: 'XXXXXXXXXtest' with blob prefix: '' failed with error: 'AzCopy.exe exited with non-zero exit code while uploading files to blob storage.' For more info please refer to https://aka.ms/azurefilecopyreadme

Script

  - task: AzureCLI@3
     displayName: Copy Latest MSI File
     inputs:
       azureSubscription: '$(svcConnection)'
       scriptType: 'pscore'
       scriptLocation: 'inlineScript'
       inlineScript: |
         $ctx = New-AzStorageContext -StorageAccountName '$(storageAccount)'
         $latestMSIFile = Get-AzStorageBlob -Container '$(containerName)' -Context $ctx | Where-Object { $_.Name -like "*.msi" } |  Sort-Object -Property LastModified -Descending | Select-Object -First 1
         Start-AzStorageBlobCopy -Context $ctx -SrcContainer '$(containerName)' -SrcBlob $latestMSIFile.Name -DestContainer '$(containerName)' -DestBlob "SmartScreenPopAssistantInstaller_latest.msi" -Force
Azure Blob Storage
Azure Blob Storage

An Azure service that stores unstructured data in the cloud as blobs.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.