New to Azure, playing with Batch Start Task RRS feed

  • Question

  • Currently doing some testing on Azure Batch (AWS guy over here) and was trying to figure out how to create an ultra-simple start up task. I wanted to test getting a test.sh file from blob storage as a resource and then simply running /bin/sh test.sh 

    This is for Ubuntu 16.04 LTS

    I want to get this working before I do anymore testing, but have been hard stuck on it. Searching forums, docs, videos, etc. But all examples seem to show Python/json/c# CLI/template examples instead of the native "Command Line" they provide so am not sure what to do.

    Start Task gets the file downloaded just fine and can see it in startup/wd/test.sh however the Command Line always fails. Any call to run it returns that the file doesn't exist or command program isn't found. I've noticed my biggest issue with the Command Line found in "start task" cannot take multiple commands, it always reads it as one line. I seem to be able to run single commands like pwd and ls, however.

    So, given a downloaded script file in the startup/wd/ folder, how can I call that file to run as a pool autouser, admin with the Command Line found in the Start Task screen?

    Let's assume the .sh is

    echo "hello world" 

    • Edited by KairuKins Thursday, August 24, 2017 12:43 AM
    Thursday, August 24, 2017 12:42 AM

All replies

  • Since you have a shebang statement and assuming you have not set a file mode on the resource file property (it will default to user/group rwx), you can simply have the commandline be ./test.sh assuming the name of the file is test.sh.

    For any task, including the start task, Batch will set the working directory for the command to the <Task>/wd. You can also explicitly create a shell for execution to invoke, so the commandline can be /bin/sh test.sh.

    You can run multiple commands without having a script file in the commandline by properly quoting and invoking a shell and the "run command" switch. For example you can do: /bin/bash -c "pwd; ls"

    One final note, please ensure that your file has unix-line endings (LF).

    Thursday, August 24, 2017 2:50 PM