I’m writing an edge module (in Node) that interacts with the Azure Blob storage modules on IoT Edge.
I’m creating a blobServiceClient exactly according to docs @ https://www.npmjs.com/package/@azure/storage-blob
The npm package uses the Service API version 2022-11-02. However, Blob storage modules on IoT Edge use the Azure Storage SDKs that are consistent with the 2017-04-17 version of the Azure Storage API for block blob endpoints.
If I try the listContainers operation as follows:
const { DefaultAzureCredential } = require("@azure/identity");
const { BlobServiceClient } = require("@azure/storage-blob");
const account = "<account>";
const defaultAzureCredential = new DefaultAzureCredential();
const blobServiceClient = new BlobServiceClient(
`https://${account}.blob.core.windows.net`,
defaultAzureCredential
);
async function main() {
let i = 1;
let containers = blobServiceClient.listContainers();
for await (const container of containers) {
console.log(`Container ${i++}: ${container.name}`);
}
}
main();
I will see the following exception:
RestError: The value for one of the HTTP headers is not in the correct format.
RequestId:42e1b7bf-1523-49df-9d42-537424d21605
Time:2023-04-15T20:40:34.6596102Z
{
“name”: “RestError”,
“code”: “InvalidHeaderValue”,
“statusCode”: 400,
“request”: {
“streamResponseStatusCodes”: {},
“url”: “http://127.0.0.1:11002/localstorageaccount/newcontainer1681591234606?restype=REDACTED”,
“method”: “PUT”,
“headers”: {
“_headersMap”: {
“x-ms-version”: “REDACTED”,
“accept”: “application/xml”,
“user-agent”: “azsdk-js-storageblob/12.14.0 (NODE-VERSION v16.20.0; Linux 5.15.90.1-microsoft-standard-WSL2)”,
“x-ms-client-request-id”: “9f67e347-9a87-48a5-aab8-49bdab7308b6”,
“x-ms-date”: “REDACTED”,
“authorization”: “REDACTED”
}
},
“withCredentials”: false,
“timeout”: 0,
“keepAlive”: true,
“decompressResponse”: false,
“requestId”: “9f67e347-9a87-48a5-aab8-49bdab7308b6”
},
“details”: {
“connection”: “close”,
“content-length”: “940”,
“content-type”: “application/xml”,
“date”: “Sat, 15 Apr 2023 20:40:34 GMT”,
“server”: “Microsoft-NetCore/2.0”,
“x-ms-request-id”: “42e1b7bf-1523-49df-9d42-537424d21605”,
“message”: “The value for one of the HTTP headers is not in the correct format.nRequestId:42e1b7bf-1523-49df-9d42-537424d21605nTime:2023-04-15T20:40:34.6596102Z”,
“code”: “InvalidHeaderValue”,
“HeaderName”: “x-ms-version”,
“HeaderValue”: “2022-11-02”,
“ExceptionDetails”: {
“ExceptionMessage”: “The value 2022-11-02 provided for request header x-ms-version is invalid.”,
“StackTrace”: “Microsoft.Cis.Services.Nephos.Common.Protocols.Rest.InvalidHeaderProtocolException: The value 2022-11-02 provided for request header x-ms-version is invalid.n at Microsoft.Cis.Services.Nephos.Common.Protocols.Rest.BasicHttpProcessorWithAuthAndAccountContainer1.RunVersionCheck()n at Microsoft.Cis.Services.Nephos.Common.Protocols.Rest.BasicHttpProcessorWithAuthAndAccountContainer
1.ProcessImpl(AsyncIteratorContext`1 async)+MoveNext()”
I think the key line here is “The value 2022-11-02 provided for request header x-ms-version is invalid.”
I’m looking for a way to explicitly set the API Version that the sdk should use but I cannot find a way. I believe that the python SDK can do this. But I can’t find a way to get around this in node.