如何在发布管道 TFS 中将文件从 Azure 文件存储复制到 Azure VM?

How to copy files from Azure File Storage to Azure VM in release pipeline TFS?

是否有任何内置的 TFS 构建任务或 PowerShell 脚本可通过 TFS 中的发布部署管道将文件从 Azure 文件存储复制到 Azure VM。我试着在网上看了一下,但没有得到任何结果。

不,我们没有这种内置任务。我们有一个 Azure File Copy task,它使用它将应用程序文件和其他工件复制到 Microsoft Azure 存储 blob 或虚拟机 (VM)。

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.

您可以在 VM 上使用 AzCopy 命令 copy/download 数据从 blob 到本地驱动程序。

  1. http://aka.ms/downloadazcopy
  2. 安装 AzCopy
  3. 阅读文档来自:https://docs.microsoft.com/en-us/azure/storage/storage-use-azcopy
  4. cd "C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy"
  5. 获取 Blob 存储(辅助)密钥
  6. Powershell:Blob 上传单个文件

    .\AzCopy /Source:C:\myfolder /Dest:<a href="https://myaccount.blob.core.windows.net/mycontainer/myfolder/" rel="noreferrer">https://myaccount.blob.core.windows.net/mycontainer/myfolder/</a> /DestKey:key /Pattern:abc.txt</pre>

  1. 登录远程虚拟机

  2. Powershell:Blob 下载单个文件

    .\AzCopy /Source:<a href="https://myaccount.file.core.windows.net/myfileshare/myfolder/" rel="noreferrer">https://myaccount.file.core.windows.net/myfileshare/myfolder/</a> /Dest:C:\myfolder /SourceKey:key /Pattern:abc.txt</pre>

对于 PowerShell,您需要在所有平台上使用 PowerShell Core 6.x 及更高版本。它适用于 Windows 和 Linux 虚拟机,使用 Windows PowerShell 5.1(仅 Windows)或 PowerShell 6(Windows 和 Linux)。

您可以在本文档中找到 PowerShell 命令:Quickstart: Upload, download, and list blobs by using Azure PowerShell