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 Answers
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.
- Install AzCopy from http://aka.ms/downloadazcopy
- Read docs from: https://docs.microsoft.com/en-us/azure/storage/storage-use-azcopy
- cd "C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy"
- Get Blob Storage (Secondary) Key
Powershell: Blob Upload single file
.\AzCopy /Source:C:\myfolder /Dest:https://myaccount.blob.core.windows.net/mycontainer/myfolder/ /DestKey:key /Pattern:abc.txt
Logon to Remote VM
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