我是 Azure 批处理新手。我必须在池中的节点上执行任务。
我使用的方法是我有想要在节点上运行的代码。我正在制作 .class 文件的 jar 的 zip 并上传到我的 Azure 存储帐户,然后获取应用程序 ID 并将其放入 ApplicationPackageReference 中并添加到我的作业任务中。
String applicationId= "TaskPerformApplicationPack";
ApplicationPackageReference reference = new ApplicationPackageReference().withApplicationId(applicationId);
List<ApplicationPackageReference> list = new ArrayList<ApplicationPackageReference>();
list.add(reference);
TaskAddParameter taskToAdd = new TaskAddParameter().withId("mytask2").withApplicationPackageReferences(list);
taskToAdd.withCommandLine(String.format("java -jar task.jar"));
batchClient.taskOperations().createTask(jobId, taskToAdd);
现在,当我运行此命令时,我的任务失败并给出错误
access for one of the specified Azure Blob(s) is denied
如何使用 azure 批处理作业任务在节点上运行特定代码?
最佳答案
我认为一个好的起点是:(我已经涵盖了大多数有用的链接以及下面的指导文档,他们将详细说明环境级别变量等的使用,我还包含了一些示例链接,例如好吧。)希望下面的 Material 和示例对您有所帮助。 :)
此外,如果池是旧的,我建议重新创建它,这将确保您的节点在最新版本上运行。
- Azure batch learning path :
- Samples & demo link或查看here
- Detailed walk through depending on what you are using i.e.
CloudServiceConfiguration
orVirtualMachineConfiguration
link.
文章中的进一步添加:另请参阅此处:Application Packages with VM configuration
特别是this链接将引导您完成如何在代码中使用它的指导过程:无论是资源文件还是包,您都需要确保它们已上传并可在批处理级别使用。
以及示例:(下面是池级 pkg 示例)
// Create the unbound CloudPool
CloudPool myCloudPool =
batchClient.PoolOperations.CreatePool(
poolId: "myPool",
targetDedicatedComputeNodes: 1,
virtualMachineSize: "small",
cloudServiceConfiguration: new CloudServiceConfiguration(osFamily: "4"));
// Specify the application and version to install on the compute nodes
myCloudPool.ApplicationPackageReferences = new List<ApplicationPackageReference>
{
new ApplicationPackageReference {
ApplicationId = "litware",
Version = "1.1" }
};
// Commit the pool so that it's created in the Batch service. As the nodes join
// the pool, the specified application package is installed on each.
await myCloudPool.CommitAsync();
对于任务级别表格,示例上方的链接为:(确保您已正确执行提到的步骤 here 。
CloudTask task =
new CloudTask(
"litwaretask001",
"cmd /c %AZ_BATCH_APP_PACKAGE_LITWARE%\\litware.exe -args -here");
task.ApplicationPackageReferences = new List<ApplicationPackageReference>
{
new ApplicationPackageReference
{
ApplicationId = "litware",
Version = "1.1"
}
};
进一步补充:无论是 CloudServiceCOhnfiguration
还是 VirtualMachineConfiguration
,应用程序包都是包含应用程序的**a .zip 文件**
任务运行应用程序所需的二进制文件和支持文件。每个应用程序包代表该应用程序的一个特定版本。来自引用:4
我尝试了一下并成功了,所以我无法复制上面的错误,看起来你可能遗漏了一些东西。
关于azure - 在 Azure 批处理上执行任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47434319/