2
votes

Is there any built-in TFS build task or PowerShell script to copy files from Azure File Storage to Azure VM via release deployment pipeline in TFS. I tried looking a bit on internet but didn't get anything fruitful.

1

1 Answers

3
votes

No, we do not have this kind of build-in task. We have a Azure File Copy task which use it copy application files and other artifacts to Microsoft Azure storage blobs or virtual machines (VMs).

When the target is Azure VMs, the files are first copied to an automatically generated Azure blob container and then downloaded into the VMs. The container is deleted after the files have been successfully copied to the VMs.

You could use AzCopy command on the VM to copy/download data from blob to local driver.

  1. Install AzCopy from http://aka.ms/downloadazcopy
  2. Read docs from: https://docs.microsoft.com/en-us/azure/storage/storage-use-azcopy
  3. cd "C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy"
  4. Get Blob Storage (Secondary) Key
  5. Powershell: Blob Upload single file

    .\AzCopy /Source:C:\myfolder /Dest:https://myaccount.blob.core.windows.net/mycontainer/myfolder/ /DestKey:key /Pattern:abc.txt
  1. Logon to Remote VM

  2. Powershell: Blob Download single file

    .\AzCopy /Source:https://myaccount.file.core.windows.net/myfileshare/myfolder/ /Dest:C:\myfolder /SourceKey:key /Pattern:abc.txt

For PowerShell, you need to use PowerShell Core 6.x and later on all platforms. It works with Windows and Linux virtual machines using Windows PowerShell 5.1 (Windows only) or PowerShell 6 (Windows and Linux).

You can find the PowerShell commands in this document: Quickstart: Upload, download, and list blobs by using Azure PowerShell