具有VM配置的应用程序包 [英] Application Packages with VM configuration

查看:91
本文介绍了具有VM配置的应用程序包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用应用程序包的描述方式




  • ==> ==>



    要进一步添加:应用程序包是一个.zip文件,其中包含应用程序二进制文件和所需的支持文件。或您运行应用程序的任务。每个应用程序包都代表该应用程序的特定版本。+



    您可以在池和任务级别指定应用程序包。创建池或任务时,您可以指定一个或多个这些软件包,也可以指定一个版本。+



    •池应用程序软件包被部署到服务器中的每个节点上。池。当节点加入池时,以及重新引导或重新映像时,将部署应用程序。
    池应用程序包适用于池中的所有节点执行作业的任务。创建池时,可以指定一个或多个应用程序包,也可以添加或更新现有池的包。如果更新现有池的应用程序包,则必须重新启动其节点以安装新程序包。



    •任务应用程序包仅部署到计划运行运行Windows Server 2003的计算节点。任务,就在运行任务的命令行之前。如果指定的应用程序包和版本已在节点上,则不会重新部署它,而是使用现有的包。
    任务应用程序包在共享池环境中很有用,在共享池环境中,一个池上运行不同的作业,并且在作业完成时不会删除该池。如果您的工作中的任务少于池中的节点,则任务应用程序包可以最大程度地减少数据传输,因为您的应用程序仅部署到运行任务的节点上。



    附加的示例包含池级别和任务级别的演示。



    步骤:




    • 首先,将一个新的应用程序包添加到我的批处理帐户中:您可以通过门户网站进行操作。 (git项目带有test1.zip以及此git示例控制台应用程序。


    • 然后打开您的 DotNetTurorial 解决方案:


    • 填写这些信息以获取批处理帐户凭据或正确使用您凭据的任何存储帐户:


    • 将启动 barebone.cs 设置为启动项目,**请注意,您可能需要更改* .proj文件,因为在我本地,所有nuget都来自 c:\cxcache




    请注意,将提示您删除作业和池,如果您要签出此应用的返回结果,请保留作业和​​池,然后进入该池内的节点并签出stdout。 (注意:您可能要在完成后从门户网站删除作业和池。)



    成功运行的屏幕截图如下:



    所以我能够看到测试成功从TaskApplication.exe的节点中的节点内部的stdout.txt中打印出来。



    此示例中使用的代码在这里存在的示例中重用了准系统应用程序:




    I'm trying to use application packages in the way they're described in this

    But I keep getting an error saying

    application path not found.

    Any ideas what could be wrong? Or

    How do application packages work in the background, that might help me debug the error?

    EDIT: I am trying to add an application package specific to my job manager task. I added the package as a zip file through Azure portal under the name JobManagerTask and version 1.0. Here is the code I'm using to reference it:

        string taskID = "tasktest1";
        // Obtain application package that has executables for job manager task
        ApplicationPackageReference jobManagerApp = new ApplicationPackageReference { ApplicationId = "JobManagerTask", Version = "1.0" };
        // Command Line
        string commandLine = @"cmd /c %AZ_BATCH_APP_PACKAGE_JOBMANAGERTASK#1.0%\\JobManagerTask.exe";
        // Create a CloudTask
        CloudTask oneTask = new CloudTask(taskID, commandLine);
        oneTask.ApplicationPackageReferences = new List<ApplicationPackageReference> { jobManagerApp };
        // Provide elevated admin access to the task
        oneTask.UserIdentity = new UserIdentity(new AutoUserSpecification(elevationLevel: ElevationLevel.Admin, scope: AutoUserScope.Task));
        // Could add task resource files if needed here
        await batchClient.JobOperations.AddTaskAsync(jobID, oneTask);
    

    解决方案

    Coool, so i created a small barebone app. :) rest details are below and please feel free to ping me if I can helpout further.

    so I tried with almost identical code like your's minus couple of flags like userIdentity and seems like I had my sample working fine, I think the error will only happen in case where the application package is not correctly refer'd. like if my *.exe reside in some diff dir structure etc. :)

    I thought it will be a good idea to create a vanilla (i.e. from scratch application for you by taking one of the existing samples.) which might give you a chance to quickly take a look and see if you missed anything.

    Please feel free to ping me and I will help you out to achieve your coal, I think its something very small like path is wrong etc. (which error message also suggest)

    The Application reside here:

    Detail:

    Detail is also there in the Readme for the git but as its a good practice in SO to detail everything here I will copy paste what I have written in readme here for you.

    quick_sample_batchapppkgworking

    Readme: barebone quick app:

    Please note thta this app is nothing but a quick sample made based on the existing sample for DotNetTutorial.

    Following code is generated just as a sample code for end to end app package working feature.

    https://docs.microsoft.com/en-us/azure/batch/

    https://docs.microsoft.com/en-us/azure/batch/batch-technical-overview

    App Pacakges:

    https://docs.microsoft.com/en-us/azure/batch/batch-application-packages

    https://azure.microsoft.com/en-us/blog/application-packages-and-task-dependencies-now-available-on-azure-batch/

    The overview as how it works is fairly simple, when user uploads to adds an application package the package becomes available within node’s working directory (wd). The env var gets created to handle multiple updated versions of the app: (the timestamp is automatically part of the App pkg populated env var you dont need to do anything to handle this.)

    set AZ_BATCH_APP_PACKAGE_TEST1#1.0=C:\user\tasks\applications\wd\test1\1.0\2017-07-14T21.45.45.765Z

    Hence if user has correct package version all set and node has app pkg they can invoke that from whatever the need is for application package: (something like this)

    string taskCommandLine = String.Format("cmd /c %AZ_BATCH_APP_PACKAGE_TEST1#1.0%\\ImageTest\\TaskApplication.exe");

    The inside implementation is fairly neat as well.

    Please note the reason:

    %AZ_BATCH_APP_PACKAGE_TEST1#1.0%\\ImageTest\\TaskApplication.exe"

    Is because my application package zip contains the TaskApplciaiton.exe under the following structure:

    ==> ==>

    To add further: An application package is a .zip file that contains the application binaries and supporting files that are required for your tasks to run the application. Each application package represents a specific version of the application.+

    You can specify application packages at the pool and task levels. You can specify one or more of these packages and (optionally) a version when you create a pool or task.+

    • Pool application packages are deployed to every node in the pool. Applications are deployed when a node joins a pool, and when it is rebooted or reimaged. Pool application packages are appropriate when all nodes in a pool execute a job's tasks. You can specify one or more application packages when you create a pool, and you can add or update an existing pool's packages. If you update an existing pool's application packages, you must restart its nodes to install the new package.

    • Task application packages are deployed only to a compute node scheduled to run a task, just before running the task's command line. If the specified application package and version is already on the node, it is not redeployed and the existing package is used. Task application packages are useful in shared-pool environments, where different jobs are run on one pool, and the pool is not deleted when a job is completed. If your job has fewer tasks than nodes in the pool, task application packages can minimize data transfer since your application is deployed only to the nodes that run tasks.

    The sample attached contains both pool level level as well the task level demo.

    Steps:

    • At first add a new Application Package into my batch account: you can do that via portal. (the git project has test1.zip along with this git sample console app.

    • Then open your DotNetTurorial solution:

    • Fill in these info for the batch account credentials or any storage account in use for your credentials correctly:

    • Hit start the barebone.cs is set as the start project, ** please note you might need to change your *.proj file, because in my local all nugets were getting sourced from c:\cxcache

    Please also note, there will be prompt to delete the job and pool, if you want to checkout the return result of this app, please keep the job and pool and then go inside node inside that pool and checkout stdout.txt file for the txt printed. (Note: you probably want to delete job and pool from the portal once you are done.)

    The screenshots from my successful run are below:

    So I was able to see the Test Success getting printed in my stdout.txt inside node from the TaskApplication.exe which was part of this application package.

    The code used in this sample barebone app is reused fomr the sample existing here: https://github.com/Azure/azure-batch-samples/tree/master/CSharp/ArticleProjects/DotNetTutorial.

    Other friendly screenshots:

    这篇关于具有VM配置的应用程序包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆