• Uncategorized

About c# : Azure-Batch-Service-Passing-Arguments-via-Command-Line-into-Application-Package-on-LinuxUbuntu

Question Detail

Given the following C#/.NET console application running on my Azure Batch Pool/Task:

class Program
    static async Task Main(string[] args)
            Console.WriteLine($"Could not parse arguments");

How can I pass the args when adding a command line to my tasks in a Linux/Ubuntu VM. I have tried the following with no success:

/bin/sh -c $AZ_BATCH_APP_PACKAGE_Program_1_0/Program -args ‘arg1’ ‘arg2’

/bin/sh -c $AZ_BATCH_APP_PACKAGE_Program_1_0/Program -args ‘arg1’, ‘arg2’

/bin/sh -c $AZ_BATCH_APP_PACKAGE_Program_1_0/Program ‘arg1’ ‘arg2’

/bin/sh -c $AZ_BATCH_APP_PACKAGE_Program_1_0/Program ‘arg1’, ‘arg2’

/bin/sh -c $AZ_BATCH_APP_PACKAGE_Program_1_0/Program -i ‘arg1’ ‘arg2’

/bin/sh -c $AZ_BATCH_APP_PACKAGE_Program_1_0/Program -i ‘arg1’, ‘arg2’

I am able to run the application but the arguments are not passed in and I only get to the “Could not parse arguments” output…

Question Answer

After throwing every variation possible at this (and looking at this example) it looks like you have to concatenate the string value of the package name with the args to the environment variable in a certain way to make sure the parameters carry through to the command.

Here is what finally did it for me

/bin/sh -c $AZ_BATCH_APP_PACKAGE_Program_1_0"/Program 'arg1' 'arg2'"

Hope this helps anyone who is looking for it!

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.