node.jstypescriptazure-table-storage

I am able to write data to Azure table storage, but I'm not able to read from table


I am using Nodejs - TS Express server. I am trying to read the data from the table called tracker which also has the partition name as tracker. I am able to write to the table with no issues, but when I'm trying to use listEntities or getEntities, I'm getting The requested operation is not implemented on the specified resource. Here is the code what I am using to get the list. I tried using the sas token as well, it too had same problem.

import { AzureNamedKeyCredential, TableClient, TableServiceClient, odata , AzureSASCredential, generateTableSas } from "@azure/data-tables";
import { Mail, MailEntity } from "../models/mail";
import { DefaultAzureCredential } from "@azure/identity";

const accountName = process.env.ACCOUNT_NAME || "";
const accountKey = process.env.ACCOUNT_KEY || "";
const tablesUrl = process.env.TABLES_URL || "";
const tableName = process.env.TABLE_NAME || "";
const sas_token = process.env.SAS_TOKEN || "";

const creds = new AzureNamedKeyCredential(accountName, accountKey)

const client = new TableClient(tablesUrl, tableName, creds);


client.listEntities({
    queryOptions: { filter: odata`PartitionKey eq tracker` }
  }).next().then((result)=>{
    result.value.entities.forEach((res:MailEntity)=>{
        console.log(res)
    })
  }).catch((error)=>{
    console.log(error.message)
    console.log("Error listing all entities")
  })

We tried a sample project in Springboot, its working just fine with the same credentials. I have also read some other people facing similar issue but they either didnt provide the solution or those solution did not work.


Solution

  • I have found the solution. I have been using Account name, Account key, SaS token etc in various combination, Nothing was working for me. But when I used the connection string like

    const client = TableClient.fromConnectionString(connectionString, tableName)

    its working as intended. But why I was able to write to DB but not read from DB still remains a mystery when I was using the Account name + Account Key combination