如何使用 powershell 将 CSV 文件直接导入到 Azure DataLake 而不是本地路径?

how to import the CSV file directly to Azure DataLake instead of local path using the powershell?

我想将 $rootfolder 值直接复制到 Azure Data Lake 存储。

我无法弄清楚将其导入 Data Lake 而不是本地路径的正确语法 "C:/"。所以我尝试从本地复制到数据湖,但它仍然显示错误并且没有被复制?

是否有任何方法可以将值直接导入到 Azure Data Lake,或者只能通过从本地复制到 Data Lake 来完成?

 function GetFolderContent 
    {
     Param(
     [string]$rootFolder
     ) 

    $items = Get-AzureRmDataLakeStoreChildItem -Account "xxx" -Path $rootFolder
       Write-Host "$rootFolder" 
       $rootFolder >> "C:\temp\abc.csv"

   `Import-AzureRmDataLakeStoreItem -Account $dataLakeStoreName -Path C:\temp -Destination $uploadDest -Concurrency` 4



    foreach ($item in $items) 
       {
         if ($item.Type -eq "DIRECTORY") 
         {
            $nextFolder = $item.Name 

             if ($rootFolder -eq "\") 
             {
               GetFolderContent $nextFolder 
             }
             else
             {
               GetFolderContent $rootFolder/$nextFolder
             }
         }
       }

          return $null 
    } 

       $rootFolder = "/" 
       $uploadDest ="/"
       $dataLakeStoreName ="xxx"
       GetFolderContent $rootFolder 

试试下面的命令,它在我这边运行良好。

$rootFolder = "/sss/"
$rootFolder >> "$env:Temp/abc.csv"

Import-AzureRmDataLakeStoreItem -Account "joydatalake1" -Path "$env:Temp/abc.csv" -Destination "/test/abc.csv" -Concurrency 4

我的数据湖:

更新:

如果要覆盖$env:Temp/abc.csvdatalake中的文件,请在命令中使用-Force,如下所示尝试。

$rootFolder = "/sss/"
$rootFolder | Out-File "$env:Temp/abc.csv" -Force

Import-AzureRmDataLakeStoreItem -Account "joydatalake1" -Path "$env:Temp/abc.csv" -Destination "/test/fgh.csv" -Concurrency 4 -Force