In Azure devops, how to copy application.zip file to blob storage?

Viewed 368

In Azure CICD , how to copy application zip file to blob storage? I have the YAML below. I want the app.zip copied to blob. The file gets copied, but for some reason, the size of the blob is 1KB. Am I doing something wrong?

Here is the code:

- task: PublishBuildArtifacts@1
  inputs:
    pathtoPublish: '$(Build.ArtifactStagingDirectory)' 
    artifactName: 'release'

- task: ArchiveFiles@2
  inputs:
    rootFolderOrFile: '$(Build.BinariesDirectory)'
    includeRootFolder: true
    archiveType: 'zip'
    archiveFile: '$(Build.ArtifactStagingDirectory)/App.zip'
    replaceExistingArchive: true

- task: AzureFileCopy@3
  inputs:
    SourcePath: '$(Build.ArtifactStagingDirectory)/App.zip'
    azureSubscription: 'testsubscription'
    Destination: 'AzureBlob'
    storage: 'teststorage'
    ContainerName: 'testcontainer'
1 Answers

Your YAML code only zip the metadata and it doesn't contain all the files in your repo. Check the below YAML code and it will move all the files to the storage account by making them as zipping.

  - task: PublishPipelineArtifact@1
       inputs:
          targetPath: '$(Pipeline.Workspace)'
          artifact: 'app'
          publishLocation: 'pipeline'

  - task: ArchiveFiles@2
          inputs:
             rootFolderOrFile: '$(Pipeline.Workspace)'
             includeRootFolder: false
             archiveType: 'zip'
             archiveFile: '$(Pipeline.Workspace)/app.zip'
             replaceExistingArchive: true

  - task: AzureFileCopy@3
          inputs:
             SourcePath: '$(Pipeline.Workspace)/app.zip'
             azureSubscription: 'testsubscription'
             Destination: 'AzureBlob'
             storage: 'sampledemozip'
             ContainerName: 'demo'
             sasTokenTimeOutInMinutes: 240
Related