Currently, I am developing an edge module using Node.js to interact with Azure Blob storage modules on IoT Edge platform.
To achieve this, I am following the documentation available at https://www.npmjs.com/package/@azure/storage-blob.
The npm package utilizes the Service API version 2022-11-02. However, the Azure Storage SDKs used by Blob storage modules on IoT Edge adhere to the Azure Storage API version 2017-04-17 for block blob endpoints.
When attempting the listContainers operation as shown below:
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();
The operation results in 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-537424d21605\nTime: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.BasicHttpProcessorWithAuthAndAccountContainer
1.RunVersionCheck()\n at Microsoft.Cis.Services.Nephos.Common.Protocols.Rest.BasicHttpProcessorWithAuthAndAccountContainer
1.ProcessImpl(AsyncIteratorContext`1 async)+MoveNext()"
The issue is clearly highlighted in the line "The value 2022-11-02 provided for request header x-ms-version is invalid."
I am seeking a solution to explicitly define the API Version that the SDK should utilize, but currently, I am unable to find a method within Node.js for achieving this. It seems that the Python SDK offers this functionality, but I have hit a roadblock while trying to resolve this in Node.js.