I'm trying to launch a VBS file as an Azure Batch Task and I'm constantly getting errors that the script file cannot be found.
Here's one command that works:
string appPath = String.Format("%AZ_BATCH_APP_PACKAGE_{0}#{1}%", appPackageId, appPackageVersion);
string taskCommandLine = String.Format("cmd /c {0}\\ffmpeg-3.4-win64-static\\bin\\ffmpeg.exe -i {1} -vcodec libx264 -crf 28 -c:a aac -b:a 128k {2} & del {3} & rename {4} {5}", appPath, inputMediaFile, outputMediaFile, inputMediaFile, outputMediaFile, inputMediaFile);
This one works correctly, but before firing ffmpeg on the input file, I'd like to do some checks with ffprobe first and doing so with a .bat kind of sucks so I tought of doing it in VBScript.
string appPath = String.Format("%AZ_BATCH_APP_PACKAGE_{0}#{1}%", appPackageId, appPackageVersion);
string taskCommandLine = String.Format("cmd /c cscript {0}\\ffmpeg-3.4-win64-static\\bin\\scan_run1.vbs {1} {2}", appPath, inputMediaFile, outputMediaFile);
Which results in:
Microsoft (R) Windows Script Host Version 5.8 Copyright (C) Microsoft Corporation. All rights reserved.
Input Error: Can not find script file "D:\batch\tasks\applications\ffmpeg3.42019-02-01-19-50\ffmpeg-3.4-win64-static\bin\scan_run1.vbs"
I'm pretty sure the vbs is there, because invoking ffmpeg.exe at the exact same location works fine.
Is the Azure Portal stripping out the VBS out of the ZIP file when I upload it as package ? What is going on there ?
Thanks.
Turns out Azure Portal is not updating the application package when I replace it. So it's got "scan_run.vbs" but not "scan_run1.vbs" even though the ZIP file on my end has it.
This will help in better understanding, essentially the short answer is this:
Reference from document here: https://learn.microsoft.com/en-us/azure/batch/batch-application-packages
Similar to a pool, you specify application package references for a task. When a task is scheduled to run on a node, the package is downloaded and extracted just before the task's command line is executed. If a specified package and version is already installed on the node, the package is not downloaded and the existing package is used.
Detail
Like I mentioned in the comments, if you have different version of application package it is recommended.
This is great that you are exploring these errors because this will help in better design of this concept around your application.
recommendations
For example: If you have all tasks sharing same application package, I would recommend using Pool Level app pkgs
https://learn.microsoft.com/en-us/azure/batch/batch-application-packages#install-pool-application-packages
If you have task level and you are changing the content of existing app pkgs
then use the app pks with version and make version different with different content of app pkgs.
How version works is detailed here:
Extras:
Little bit in detail as to how many environment variables and types: https://learn.microsoft.com/en-us/azure/batch/batch-compute-node-environment-variables
Common Gotchas
non async
behaviour leads to an issue, so always wait for the uplaod to finish before Batch creates a pool and proceeds.