如何从Azure数据工厂运行PowerShell [英] How to run PowerShell from Azure Data Factory

查看:53
本文介绍了如何从Azure数据工厂运行PowerShell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有PowerShell脚本,该脚本每1000条记录将一个复杂的CSV文件拆分为一个较小的CSV文件.这是代码:

I have PowerShell script which splits a complex CSV file to a smaller CSV file for every 1000 records. Here is the code:

$i=0;Get-Content C:\Users\dell\Desktop\Powershell\Input\bigsizeFile.csv -ReadCount 1000 | %{$i++; $_ | Out-File C:\Users\dell\Desktop\Powershell\Output\file$i.csv
}

现在,我想在Azure PowerShell中使用此脚本,并希望从Azure Data Factory运行它.有人可以帮忙吗?

Now I want to use this script in Azure PowerShell and I want to run this from Azure Data Factory. Can Someone please help with this.

推荐答案

通过将脚本作为应用程序加载到与批处理自定义活动关联的批处理帐户中,我能够运行PowerShell脚本.从那里开始,找出正确的语法糖来使用环境变量来获取我的脚本的路径并运行它.我这样做是这样的:

I was able to run a PowerShell script by loading the script as an application in the Batch account associated to the Batch Custom Activity. From there it was figuring out the correct syntactical sugar to use the environment variables to get the path to my script and run it. I did this like so:

powershell powershell -command (\"(Get-ChildItem Env:AZ_BATCH_APP_PACKAGE_powershellscripts#1.0).Value\" + '\\Powershell\\processFromAzure.ps1

如果您只想从任务目录中调用,这应该可以工作:

If you just want to call from the task dir, this should work:

powershell powershell -command ("$env:AZ_BATCH_TASK_DIR" + '\wd\processFromAzure.ps1')

希望这可以帮助其他人!

Hope this helps someone else out there!

这篇关于如何从Azure数据工厂运行PowerShell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆