从 Datafactory 在 VM 上调用 'Run Command' 的规范方法?

Canonical way to call 'Run Command' on a VM from Datafactory?

我需要执行位于资源组内的 VM 中的各种批处理脚本。这些脚本的调用需要Datafactory来编排。

我了解了 VM 中的 Run Command,可以通过 PowerShell 或 Rest API 使用它。我想知道是否建议将这些方法中的任何一种包含在 Datafactory 管道中。

此时我的方法是使用 Web Activity 进行 API 调用,每个脚本一个。

我的问题:是否有更推荐的方法来做到这一点?您是否看到任何可能成为此方法问题的瓶颈或情况?

我认为这是最简单的实现方式,使用Web activity时需要注意的一点是Authentication,记得选择Managed Identity,并用 https://management.azure.com/.

指定 Resource

要在 Web activity 中成功调用 REST API - Virtual Machines Run Commands - Run Command,您还需要将 RBAC 角色授予托管身份 (MSI)。

导航到门户中的订阅或 VM -> Access control (IAM) -> Add -> Add role assignment -> 搜索 ADFv2 的名称并将其添加为Owner/Contributor角色。

如果您不熟悉托管身份 (MSI),请参阅此 doc. Also make sure your ADFv2 has the MSI, when creating data factory through Azure portal or PowerShell, managed identity will always be created automatically, if not, follow this 以生成托管身份。