How to create proper REST authorization and headers RRS feed

  • Question

  • I have been trying in vain to produce a working REST call to either add a task to a job or just get tasks from a job. I can't seem to locate any working examples of setting up a request. I have a tool that shows the job is running and that tool is a windows program. However, I am trying to create a SharePoint Provider Hosted add-in that allows me to send files to Azure batch for processing. The batch service is there and I can manually use the windows tool, but I need to do this from a REST call but have no real starting point for this.
    Monday, December 11, 2017 6:11 PM

All replies

  • There are two options,

    1. You can use one of our SDK libraries to send requests to the batch service. See https://github.com/Azure/azure-batch-samples for samples. We have support in many languages (.NET, python etc.)

    2. If you are looking for directly building a REST endpoint you could look at the source code for our SDK libraries (here's one example https://github.com/Azure/azure-sdk-for-net/tree/psSdkJson6/src/SDKs/Batch ) and its build instructions.


    Tuesday, December 12, 2017 4:57 PM
  • First, we highly recommend you to use standard Azure Batch SDK, since we will update them to latest REST API version.

    Second, there are 2 ways to authenticate with Azure Batch: AAD (https://docs.microsoft.com/en-us/azure/batch/batch-aad-auth) or Shared Key (https://docs.microsoft.com/en-us/rest/api/batchservice/authenticate-requests-to-the-azure-batch-service). 

    Third, for shared key auth, there are other languages you can reference to: Python (https://github.com/Azure/azure-sdk-for-python/blob/master/azure-batch/azure/batch/batch_auth.py) or node js (https://github.com/Azure/azure-sdk-for-node/blob/master/lib/services/batch/lib/batchSharedKeyCredentials.js).

    Xing Wu (MSFT)

    Tuesday, December 12, 2017 9:05 PM
  • For search indexing and clarity for other readers, there are two categories of calls into Azure Batch:

    1: ARM (Azure Resource Manager/"management plane"):

          Account CRUD, AppPackage CRUD, (new) Pool/Certificate CRUD

          This approach only supports AAD auth

    2: "data plane": pool/cert/job/task/etc CRUD:

         This approach originally supported only shared key auth but now supports both shared key and AAD.

    Since the examples given here are about jobs/tasks we can assume this is a data plane auth question.  But it could easily have been about listing/adding accounts or (now/newly available) certs/pools and been a management plane (ARM) question.


    • Edited by DarylMsft Tuesday, December 12, 2017 9:23 PM spelling/cap
    Tuesday, December 12, 2017 9:21 PM