Azure Batch获取节点文件遇MissingRequiredQueryParameter错误求解
Hey there, let's get this sorted out quickly! The error you're seeing is straightforward—you're missing the mandatory api-version query parameter that Azure Batch's REST API requires for every request. Here's exactly how to fix it:
Step 1: Add the api-version Parameter to Your URL
Append the api-version parameter to the end of your request URL using the format ?api-version=<valid-version-number>. For example, using a stable version compatible with your 2018-era request, your modified URL would look like this:
https://ResourceName.southcentralus.batch.azure.com/jobs/adfv2-ResourceName/tasks/adaa9831-fca7-4562-8a7b-8aed60de151f/files/wd/filename.dat?api-version=2018-03-01.6.0
Step 2: Choose a Valid API Version
Make sure you pick an API version that matches your Azure Batch service instance. Back in 2018, 2018-03-01.6.0 was a widely used stable version. If you're working with a newer Batch deployment later on, you can use more recent versions like 2023-11-01.19.0—just ensure the version aligns with your service's capabilities.
Step 3: Include Proper Authentication
Even with the api-version added, you'll need valid authorization to access the task file. You can use either:
- An Azure AD access token (passed in the
Authorizationheader asBearer <your-token>) - Your Batch account's access key (used to sign the request)
For example, if testing with curl, your command would look like this:
curl -H "Authorization: Bearer <your-azure-ad-token>" "https://ResourceName.southcentralus.batch.azure.com/jobs/adfv2-ResourceName/tasks/adaa9831-fca7-4562-8a7b-8aed60de151f/files/wd/filename.dat?api-version=2018-03-01.6.0"
Once you add the api-version parameter and valid authentication, your GET request should successfully retrieve the file from the Batch node storage.
内容的提问来源于stack exchange,提问作者Sauron

