locked
Cannot add CloudTask to Azure Batch. RRS feed

  • Question

  • I get an exception when try to add cloud task, width description "The remote server returned an error: (400) Bad Request.", at this line:

    _job.AddTask(task);

    of this method:

    public static void AddTask(string taskId, string commandLine, IEnumerable<string> files)
            {
                var resourceFiles = files.Select(file => new ResourceFile(file, file)).Cast<IResourceFile>().ToList();
                var task = new CloudTask(taskId, commandLine) {ResourceFiles = resourceFiles};
                _job.AddTask(task);
            }
    Sunday, January 11, 2015 3:10 PM

Answers

  • Hello Dmitry,

    Usually there is a bit more error detail as to what is the cause of the "(400 Bad Request)" in the detailed error property of the exception which can help track down what exactly the cause of the bad request is.

    To access this information you need to look at the BatchException AzureError property.  This post outlines one way to find that property.

    From my initial inspection of your code, I think what you will find is that the detailed error says something about poorly formed resource file URIs.  This is because each ResourceFile for a task must reside in Azure Storage (see Batch getting started guide "Update Task Submission code" section for more details).  It looks like in your snippet the resourceFile is being created by doing:

    new ResourceFile(file, file)

    but this should be

    new ResourceFile(storageBlobUri, file)

    Hope that helps.

    -Matt

    Monday, January 12, 2015 5:25 PM

All replies

  • Hello Dmitry,

    Usually there is a bit more error detail as to what is the cause of the "(400 Bad Request)" in the detailed error property of the exception which can help track down what exactly the cause of the bad request is.

    To access this information you need to look at the BatchException AzureError property.  This post outlines one way to find that property.

    From my initial inspection of your code, I think what you will find is that the detailed error says something about poorly formed resource file URIs.  This is because each ResourceFile for a task must reside in Azure Storage (see Batch getting started guide "Update Task Submission code" section for more details).  It looks like in your snippet the resourceFile is being created by doing:

    new ResourceFile(file, file)

    but this should be

    new ResourceFile(storageBlobUri, file)

    Hope that helps.

    -Matt

    Monday, January 12, 2015 5:25 PM
  • Thank you, really, I forgot that I must specify the full path to the file. And thank you very much for the material on exceptions.
    Monday, January 12, 2015 5:57 PM