【问题标题】:convert Csv file into Xml on Azure data lake store using Azure Powershell runbook使用 Azure Powershell Runbook 将 Csv 文件转换为 Azure 数据湖存储上的 Xml
【发布时间】:2018-08-29 15:59:13
【问题描述】:

我想使用 Azure Powershell 将 CSV 文件转换为 Azure 数据湖存储上的 XML。 我在 Azure 自动化运行手册 上使用了这段代码 它运行良好,但 没有生成 XML

$cred = Get-AutomationPSCredential -Name 'xyz'
$subscriptionName = 'Pay-As-You-Go'
$null = Add-AzureRmAccount -Credential $cred
Select-AzureRmSubscription -SubscriptionName $subscriptionName | Out-Null 
$adla = "TestAzure"
$obj = Get-AzureRmDataLakeStoreItem -AccountName $adla -Path "/custom/logile/masters/Test/Test.csv" 
 $xmlobj = ConvertTo-Xml -InputObject $obj -As 'string' 
$xmlobj | Out-File -FilePath "/custom/logile/masters/Test/xmlOut.xml"

此代码在此处运行“$obj= Get”之前运行良好,但我无法写入 Azure 数据湖。 有什么方法可以使用 Object 在 Azure 数据湖中写入文件。

【问题讨论】:

  • 为什么不能用Import-AzureRmDataLakeStoreItem上传文件?代码运行后$obj的内容是什么?
  • @l--''''''------'''''''''''' 你有/custom/logile/masters/Test/的写权限吗?

标签: powershell azure-data-factory azure-data-lake azure-runbook


【解决方案1】:

感谢您与我们联系!

您尝试使用 Out-File cmdlet 将 xml 文件导出到当前 Azure 自动化执行实例中不存在的路径 /custom/logile/masters/Test。而且您没有将 xml 文件上传到 Data Lake Store。

要满足您的要求,您必须通过替换运行手册中的最后一行来使用以下命令(即,最后一行是 $xmlobj | Out-File -FilePath "/custom/logile/masters/Test/xmlOut.xml"

$xmlobj | Out-File -FilePath "$env:temp/xmlOut.xml"
Import-AzureRmDataLakeStoreItem -AccountName $adla -Path "$env:temp/xmlOut.xml" -Destination "/custom/logile/masters/Test/xmlOut.xml"

我已经测试成功了。如果有兴趣,您可以查看下面的屏幕截图以获取说明。

请注意,上面屏幕截图中我的运行手册的前几行与您的有点不同,因为我已授予自动化帐户 RunAs 帐户对 Data Lake 存储目标文件夹的权限。所以你可以忽略这部分。

希望这会有所帮助!!干杯!!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-29
    • 1970-01-01
    • 2021-12-12
    • 1970-01-01
    • 2019-04-22
    • 1970-01-01
    • 1970-01-01
    • 2020-11-09
    相关资源
    最近更新 更多