英文:
How I can call pre-installed application in Azure Batch task?
问题
我已经将 sqlcmd 实用程序安装到 Azure Batch 节点中(这是常规的 Windows 虚拟机)。因此,在此虚拟机上有 bcp 实用程序。我如何在 Azure Batch 作业中指定 bcp.exe 的路径?
使用以下代码:
using (BatchClient batchClient = BatchClient.Open(cred))
{
string jobId = "1";
CloudJob job = batchClient.JobOperations.GetJob(jobId);
job.Commit();
string taskCommandLine = "cmd c/ 'D:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\0\\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 = "cmd c/ 'D:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\0\\Tools\\Binn\\bcp.exe'";
英文:
I installed sqlcmd utility into Azure Batch Node (this is regular windows VM). So, I have bcp utility on this VM. How I can specify path to bcp.exe in Azure Batch job?
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\0\\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);
}
Is it right way to specify full path like
string taskCommandLine = String.Format("cmd c/ 'D:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\0\\Tools\\Binn\\bcp.exe'");
答案1
得分: 2
你有几种方法可以在不同路径中启动命令:
- 在
PATH
环境变量中指定可执行文件目录。确保你正在使用一个shell命令(cmd.exe
)。 - 将你的工作目录更改为正确的目录,其中包含可执行文件。
- 根据你在任务命令行中的帖子指定完整路径。
对于你的特定情况,你的命令格式不正确。在使用cmd.exe
执行时,它应该是 cmd.exe /c <your command>
。
英文:
You have a few ways to launch a command in a different path:
- Specify the executable directory in the
PATH
environment variable. Ensure you are using a shell command (cmd.exe
). - Change your working directory to the correct directory with the executable
- Specify the full path as per your post in the task command line.
For your particular case, your command is malformed. When executing with cmd.exe
, it should be cmd.exe /c <your command>
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论