azure - 如何在 Azure Batch 任务中调用预安装的应用程序?
问题描述
我将 sqlcmd 实用程序安装到 Azure Batch 节点(这是常规的 Windows VM)。所以,我在这个虚拟机上有 bcp 实用程序。如何在 Azure Batch 作业中指定 bcp.exe 的路径?
using (BatchClient batchClient = BatchClient.Open(cred))
{
string jobId = "1";
CloudJob job = batchClient.JobOperations.GetJob(jobId);
job.Commit();
string taskCommandLine = String.Format("cmd c/ 'D:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\130\\Tools\\Binn\\bcp.exe'");
string uniqueIdentifier = Regex.Replace(Convert.ToBase64String(Guid.NewGuid().ToByteArray()), "[/+=]", "");
string taskId = String.Format(name.Replace(".", string.Empty) + "-" + uniqueIdentifier);
CloudTask task = new CloudTask(taskId, taskCommandLine);
task.UserIdentity = new UserIdentity(new AutoUserSpecification(elevationLevel: ElevationLevel.Admin, scope: AutoUserScope.Task));
batchClient.JobOperations.AddTask(jobId, task);
}
指定完整路径是否正确
string taskCommandLine = String.Format("cmd c/ 'D:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\130\\Tools\\Binn\\bcp.exe'");
解决方案
您有几种方法可以在不同的路径中启动命令:
PATH
在环境变量中指定可执行目录。确保您使用的是 shell 命令 (cmd.exe
)。- 使用可执行文件将您的工作目录更改为正确的目录
- 根据您在任务命令行中的帖子指定完整路径。
对于您的特定情况,您的命令格式错误。执行时cmd.exe
,应该是cmd.exe /c <your command>
.
推荐阅读
- .htaccess - 所有页面的单独 301 重定向,包括根 (.htaccess)
- python - 从另一个 .py 文件导入函数不仅仅导入该函数?
- ember.js - 升级到 Ember-Data 2.14 破坏了 hasMany 上的计算过滤器
- ios - 暂停游戏后如何从停止的地方重新启动游戏计时器?
- r - Docker compose - R 服务器 - 致命错误:您必须指定“--save”、“--no-save”或“--vanilla”
- javascript - 添加到数组后更改对象的值
- python - 将 pandas.DataFrame 列分配给具有默认值的系列
- c++ - C++中的多维变长数组
- http - 错误:该 URL 未使用可识别的协议
- json - 在 Swift 4 中使用可编码解析嵌套的 JSON