Azure-Functions icon indicating copy to clipboard operation
Azure-Functions copied to clipboard

Azure Function Linux Nodejs and @azure/storage-blob gives error: Cannot read property 'startsWith' of undefined

Open DaCao opened this issue 1 year ago • 2 comments

I am testing my Azure Nodejs Linux function locally and this code:

import { BlobServiceClient } from "@azure/storage-blob";

const connectionString = process.env[
  "AZURE_STORAGE_CONNECTION_STRING"
] as string;

export const blobServiceClient =
  BlobServiceClient.fromConnectionString(connectionString);

is generating this error message:

john@MacBook-Pro:~/myApp/code/seal/azure_function$ rm -rf dist/ && npm run-script build &&  func start 

> [email protected] build /Users/john/myApp/code/seal/azure_function
> tsc && tsc-alias


Azure Functions Core Tools
Core Tools Version:       4.0.5198 Commit hash: N/A  (64-bit)
Function Runtime Version: 4.21.1.20667


Functions:

        sealworker: [GET,POST] http://localhost:7071/api/sealworker

For detailed output, run func with --verbose flag.
[2023-08-15T09:06:03.440Z] Worker was unable to load entry point "dist/sealworker/index.js": Cannot read property 'startsWith' of undefined
[2023-08-15T09:06:03.551Z] Worker process started and initialized.
[2023-08-15T09:06:03.564Z] Worker was unable to load function sealworker: 'Cannot read property 'startsWith' of undefined'
[2023-08-15T09:06:03.568Z] Worker failed to load function: 'sealworker' with functionId: 'c146c9d1-05ef-4aa2-bb18-d436186b7f65'.
[2023-08-15T09:06:03.568Z] Result: Failure
[2023-08-15T09:06:03.568Z] Exception: Worker was unable to load function sealworker: 'Cannot read property 'startsWith' of undefined'
[2023-08-15T09:06:03.568Z] Stack: TypeError: Worker was unable to load function sealworker: 'Cannot read property 'startsWith' of undefined'
[2023-08-15T09:06:03.568Z]     at extractConnectionStringParts (/Users/john/myApp/code/seal/azure_function/node_modules/@azure/storage-blob/dist/index.js:13654:26)
[2023-08-15T09:06:03.568Z]     at Function.fromConnectionString (/Users/john/myApp/code/seal/azure_function/node_modules/@azure/storage-blob/dist/index.js:24328:32)
[2023-08-15T09:06:03.569Z]     at Object.<anonymous> (/Users/john/myApp/code/seal/azure_function/dist/sealworker/utils/Azure/blobServiceClient.js:6:62)
[2023-08-15T09:06:03.569Z]     at Module._compile (internal/modules/cjs/loader.js:1068:30)
[2023-08-15T09:06:03.569Z]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
[2023-08-15T09:06:03.569Z]     at Module.load (internal/modules/cjs/loader.js:933:32)
[2023-08-15T09:06:03.569Z]     at Function.Module._load (internal/modules/cjs/loader.js:774:14)
[2023-08-15T09:06:03.569Z]     at Module.require (internal/modules/cjs/loader.js:957:19)
[2023-08-15T09:06:03.569Z]     at Object.apply (/usr/local/Cellar/azure-functions-core-tools@4/4.0.5198/workers/node/dist/src/worker-bundle.js:2:44135)
[2023-08-15T09:06:03.569Z]     at require (internal/modules/cjs/helpers.js:88:18)
[2023-08-15T09:06:03.569Z]     at Object.<anonymous> (/Users/john/myApp/code/seal/azure_function/dist/sealworker/services/attachment.js:58:29)
[2023-08-15T09:06:03.571Z]     at Module._compile (internal/modules/cjs/loader.js:1068:30)
[2023-08-15T09:06:03.571Z]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
[2023-08-15T09:06:03.571Z]     at Module.load (internal/modules/cjs/loader.js:933:32)
[2023-08-15T09:06:03.571Z]     at Function.Module._load (internal/modules/cjs/loader.js:774:14)
[2023-08-15T09:06:03.571Z]     at Module.require (internal/modules/cjs/loader.js:957:19).
[2023-08-15T09:06:03.785Z] Host lock lease acquired by instance ID '000000000000000000000000DB4F1B81'.
^C[2023-08-15T09:34:22.578Z] Language Worker Process exited. Pid=53985.
[2023-08-15T09:34:22.578Z] node exited with code 130 (0x82). .

This is really odd. Why is simply importing it giving an error?

DaCao avatar Aug 15 '23 09:08 DaCao

Thanks for reporting plz share repro steps

bhagyshricompany avatar Aug 16 '23 06:08 bhagyshricompany

no input hence closed

bhagyshricompany avatar Sep 12 '23 12:09 bhagyshricompany