0

I’m developing a SPFx application customizer. One of the requirements is to connect to Azure Data Table to retrieve a list of all entities. I’m trying to generate a SAS token in my SPFx extension code to connect to the data table. I’m using the below sample provided for @Azure/Data-table in Azure SDK. I’m getting an error on the generateSasTable() function.

  console.log("== Generate Table Account SAS Sample ==");

  // We need a NamedKeyCredential to generate the SAS token
  const cred = new AzureNamedKeyCredential(accountName, accountKey);

  const tablePermissions: TableSasPermissions = {
    // Allows adding entities
    add: true,
    // Allows querying entities
    query: true,
    // Allows deleting entities
    delete: true,
    // Allows updating entities
    update: true
  };
  const anHourFromNow = Date.now() + 60 * 60 * 1000;


  // Create the table SAS token
  const tableSas = generateTableSas(tableName, cred, {
    expiresOn: new Date(anHourFromNow),
    permissions: tablePermissions
  });
  console.log(tableSas);

  const table = new TableClient(tableUrl, tableName, new AzureSASCredential(tableSas));

  // List all the entities in the table
  const entities = table.listEntities();
    for await (const entity of entities) {
    console.log(entity);
  }

The error I receive is as per below:

computeHMACSHA256.browser.js:4 Uncaught (in promise) Error: computeHMACSHA256 is not supported in the browser
at computeHMACSHA256 (computeHMACSHA256.browser.js:4:1)
at generateTableSasQueryParameters (tableSasSignatureValues.js:59:40)
at generateTableSas (generateTableSas.js:31:48)
at GlobalNavBar.tsx:160:40
at step (cli-options.js:11:1)
at Object.next (cli-options.js:11:1)
at cli-options.js:11:1
at new Promise ()
at rjVx.__awaiter (cli-options.js:11:1)
at generateTableSasToken (GlobalNavBar.tsx:137:41)

The account that I’m using has Storage Table Data Contributor role.

I’m not sure what this error means. Has anyone received this error previously?

Thanks

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.