【问题标题】:How to copy a file from Azure Storage fileshare to Release pipeline agent如何将文件从 Azure 存储文件共享复制到发布管道代理
【发布时间】:2020-08-24 16:47:06
【问题描述】:

我想将 FileShare 中 Azure 文件存储中的文件下载到我的发布管道代理中。

在发布管道中,我使用 PowerShell 步骤并运行命令:

Start-AzStorageFileCopy    -SrcShareName "report.xml" -SrcFilePath "."  -DestFilePath "$(System.DefaultWorkingDirectory)" -DestShareName  "report.xml" -Context $(context)

它现在要求我提供参数 -name

2020-05-09T01:43:34.1007773Z ##[error]Cannot process command because of one or more missing mandatory parameters: Name.

基本上,我的计划是将此文件用于发布管道中的测试报告。因此,我需要在发布测试结果步骤中使用此文件。

【问题讨论】:

  • 无法获得最新信息,解决方法对您有帮助吗?或者,如果您有任何疑问,请随时在此处分享。
  • 这有点棘手,但如果其他人也有同样的问题。 1 - 将 Azure 存储帐户装载到容器。 2 - 将文件复制到已安装的卷(必须进入睡眠状态。运行我的 testcafe 后文件为空白) 3 - 运行 Azure PowerShell 并将文件复制到代理工作目录。 4 - 在发布测试结果时获取文件。

标签: azure azure-devops azure-pipelines azure-files


【解决方案1】:

您希望从发布代理作业在本地下载文件,所以我会坚持使用以下命令:

Get-AzStorageFileContent -Context $Context -ShareName "acishare" -Path "report.xml" -Destination $(System.DefaultWorkingDirectory)

【讨论】:

    【解决方案2】:

    由于您尝试从 Azure 文件共享下载单个 report.xml 文件,请直接使用 Get-AzureStorageFileContent 命令。

    示例:

    $ctx = New-AzureStorageContext [storageaccountname] [storageaccountkey]
    
    ##sharename is your existed name.
    
    $s = Get-AzureStorageShare [sharename] –Context $ctx
    
    ##To download a file from the share to the local computer, use Get-AzureStorageFileContent.
    
    Get-AzureStorageFileContent –Share $s –Path [path to file on the share] [path on local computer]
    

    如果你想使用一个命令下载多个文件,你可以使用Azcopy

    更多详细信息请查看blog

    【讨论】:

      猜你喜欢
      • 2021-03-09
      • 2022-11-11
      • 2021-02-22
      • 1970-01-01
      • 2022-01-07
      • 2016-05-29
      • 1970-01-01
      • 2022-09-28
      • 1970-01-01
      相关资源
      最近更新 更多