【问题标题】:Downloading a file from Adls gen1 using powershell is not working使用 powershell 从 Adls gen1 下载文件不起作用
【发布时间】:2020-06-02 15:20:32
【问题描述】:

我正在尝试使用 powershell 脚本从 azure 数据湖存储下载文件。该代码是从 azure 云中的运行手册触发的。看起来Export-AdlStoreItem 没有按预期工作。我没有收到任何错误消息或编译错误。实际上,当执行此命令时,会在目标中生成一个零字节文件。该文件的名称是TemporaryFile2020-06-02_14-56-57.datc18371c2-d39c-4588-9af0-93aa3e136b01Segments 发生了什么事?请帮忙!

$LocalDwldPath = "T:\ICE_PROD_DATA_SOURCING\FILE_DOWNLOAD_PATH\TemporaryFile$($TimeinSec).dat"
    $SourcePath = "Dataproviders/Landing/GCW/HPIndirect/Orders/AMS/gcw_hp_indirect_orders_ams_745_20200601_04_34_01.dat"
    $PRODAdlsName = "itgdls01"
    Export-AdlStoreItem  -Account $PRODAdlsName -Path  $("/" + $SourcePath.Trim()) -Destination $LocalDwldPath -Force -ErrorAction Stop
    if( Test-Path $LocalDwldPath.Trim() )
    {
    Get-Content -Path $LocalDwldPath.Trim() -ReadCount 1000 |% { $FileCount += $_.Count }   
        Remove-Item $LocalDwldPath.Trim()
        Set-Content -Path $cntCaptureFile -Value $FileCount
        $TimeinSec = TimeStamp2
        Add-Content -Value "$TimeinSec Log: Identified file for getting count is $($SourcePath.Trim()) and the count is $FileCount" -Path $logfile  
    }
    else
    {                       
        $TimeinSec = TimeStamp2     
        Add-Content -Value "$TimeinSec Error: Identified file for getting count is $($SourcePath.Trim()) and the count capture failed as local file is not found!" -Path $logfile
    }   

【问题讨论】:

    标签: azure powershell azure-data-lake


    【解决方案1】:

    根据我的研究,如果你想用PowerShell从Azure数据湖下载文件,我们可以使用PowerShell命令Export-AzDataLakeStoreItem

    例如

    Export-AzDataLakeStoreItem -Account <> -Path '/test/test.csv' -Destination 'D:\myDirectory\test.csv'
    

    更多详情请参考document

    【讨论】:

      【解决方案2】:

      问题在于本地下载路径/目标 ("T:\ICE_PROD_DATA_SOURCING\FILE_DOWNLOAD_PATH\TemporaryFile$($TimeinSec).dat")。 T:\ 驱动器是作为 Azure 文件共享连接的虚拟驱动器/网络驱动器。

      而不是 T:\ ,我已将目标位置指向本地驱动器 ("F:\ICE_PROD_DATA_SOURCING\FILE_DOWNLOAD_PATH\TemporaryFile$($TimeinSec).dat"),它运行良好。

      令人惊讶的是,当 Powershell 无法将文件保存在指向 azure 文件共享的网络路径中时,它没有给出任何错误消息。

      【讨论】:

        猜你喜欢
        • 2021-02-11
        • 1970-01-01
        • 1970-01-01
        • 2013-09-22
        • 2012-11-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-01-24
        相关资源
        最近更新 更多