简体   繁体   English

Azure 批处理 - 资源文件准备任务

[英]Azure Batch - ResourceFiles PreparationTask

I'm trying to use a PreparationTask to grab my ResourceFiles to be used as input data.我正在尝试使用 PrepareTask 来获取我的 ResourceFiles 以用作输入数据。

My prep task looks like this:我的准备任务如下所示:

myJob.JobPreparationTask = new JobPreparationTask { CommandLine = jobPrepCmdLine };

How do I configure my job with a PreparationTask to download ResourceFiles from my AutoStorageContainer to pool VM's?如何使用 PreparationTask 配置我的作业以从我的 AutoStorageContainer 下载 ResourceFiles 到池 VM?

I tried:我试过了:

var inputFiles = new List<ResourceFile> { };
var file = ResourceFile.FromAutoStorageContainer("fgrp-jill2");  
inputFiles.Add(file); 

myJob.JobPreparationTask.ResourceFiles = inputFiles;

But get a null object error, even when the inputFiles.Add is showing at least 1 file recognized.但是得到一个 null object 错误,即使 inputFiles.Add 显示至少 1 个文件被识别。

You should use the Storage SDK in conjunction with Batch in this scenario.在这种情况下,您应该将 Storage SDK 与 Batch 结合使用。 You can follow this as an example: https://docs.microsoft.com/en-us/azure/batch/quick-run-dotnet#preliminaries您可以以此为例: https://docs.microsoft.com/en-us/azure/batch/quick-run-dotnet#preliminaries

A Job preparation task functions very similar to a regular Start Task in that it runs before the tasks execution.作业准备任务的功能与常规启动任务非常相似,因为它在任务执行之前运行。 In the example from the link, you'll see that we reference the Blob client, container name and file path.在链接的示例中,您将看到我们引用了 Blob 客户端、容器名称和文件路径。 I'll paste the sample here:我将在此处粘贴示例:

List<string> inputFilePaths = new List<string>
{
    "taskdata0.txt",
    "taskdata1.txt",
    "taskdata2.txt"
};

List<ResourceFile> inputFiles = new List<ResourceFile>();

foreach (string filePath in inputFilePaths)
{
    inputFiles.Add(UploadFileToContainer(blobClient, inputContainerName, filePath));
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM