2

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);
Tats_innit
  • 33,991
  • 10
  • 71
  • 77
J.B
  • 137
  • 2
  • 16
  • Hiya, can you please share the code which you have tried:also I hope you are correctly accessing the ```%AZ_BATCH_APP_PACKAGE_``` also checkout this doc in here: https://learn.microsoft.com/en-us/azure/batch/batch-dotnet-get-started , I hope I can replicate and help you out with this issue bro `:)` will wait for your reply. – Tats_innit Jul 14 '17 at 00:52
  • @Tats_innit I just added the code snippet to my post. Thanks! – J.B Jul 14 '17 at 02:23
  • saweeet, thanks @J.B., I will try it out and see if I can replicate it, in either case I will try and create a barebone code for you so that you can take a look. `:)` – Tats_innit Jul 14 '17 at 02:46
  • @Tats_innit That would be great! Thanks! – J.B Jul 14 '17 at 02:56
  • Update: Cool, so just keeping you updated: @J.B , I have a sample almost ready, just stripping out some credentials etc, Will update that as an Answer to this post and then we can see how your app is mis-behaving, it could be as minor as wrong path et. al., I will reply to your original post once I am done with a sample in git repo. `:)` – Tats_innit Jul 15 '17 at 01:59

1 Answers1

2

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://learn.microsoft.com/en-us/azure/batch/

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

App Pacakges:

https://learn.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:

zip file ==> underlying folder ==> main exe file which will get used by this sample

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:

Files inside nodes with app package available another simple view of files inside node Successful run This is view from batch explorer

Tats_innit
  • 33,991
  • 10
  • 71
  • 77
  • thank you very much for your elaborate and detailed answer! Appreciate it! Unfortunately, I still get the same error. And I think that the problem is that there is no applications folder or files. Do you know what could be causing that? Also, I see that you ran your test with CloudConfiguration, and I'm actually using VM configuration for the pool. Would that make a difference? Thanks – J.B Jul 18 '17 at 16:33
  • I actually just found the issue. I was testing application packages in a VM pool that I created before they added app packages to the VM configuration. – J.B Jul 18 '17 at 16:49
  • @J.B Awesome `:)` Glad it helped, Nice, Ah, yeah its important that before using i.e. referencing app kg make sure app pkg are there. – Tats_innit Jul 19 '17 at 11:32
  • I have one more quick question about application packages if you don't mind. So if I added an application package when creating a pool so that it is installed on all nodes, can I just invoke it in all my tasks from command line, or do I need to reference it from scratch in each task the same way I'd do when adding a task specific application package if that makes sense? – J.B Jul 19 '17 at 21:48
  • @J.B all good, yep if the app package is available at pool level, then all you need is to reference that app package when you create task, thats it, when the new node will join pool it will be aware about that `app_pkg` hence the command line will work fine. **Please Note** : do mention that app pkg when you refer create task. also this case fits the first part of the app pkg docs in msdn i.e. pool level application. `:)` rest should be awesome. Thanks. – Tats_innit Jul 19 '17 at 21:52
  • I got confused by your note. Say the application package is already installed in all nodes and I can see it in apppackages, now when creating a task that uses the application package, do I need: ApplicationPackageReference taskApp = new ApplicationPackageReference { ApplicationId = "TestApplication", Version = "1.0" }; oneTask.ApplicationPackageReferences = new List { taskApp }; or can I get things working without that nd go straight to command line? – J.B Jul 19 '17 at 22:04
  • `:)` Ah, cool, nopes, if you can see that app pkgs are there in node then nopes, no need to do the above line of code. ALl you need is command line and it should be fine. I guess I was trying to also explain the other case where you can also have task level unique app pkg but for now, answer is that if you can see that app_pkgs are already in node then no need to mention `new ApplicationPackageReference { ApplicationId = "TestApplication", Version = "1.0" };` – Tats_innit Jul 19 '17 at 22:10
  • 1
    Great! That answers my question! Thanks for clearing the confusion :)! – J.B Jul 19 '17 at 22:27