Mark
Mark

Reputation: 858

Azure Function dependencies - Invalid ELF header

I'm trying to run an Azure Function that has a dependency on TensorflowJS, resulting in an invalid ELF header. I know this is usually a sign that the dependency has been built for a different architecture. That makes sense in this case, locally I'm running OSX and deploying to Linux.

The deployment works fine via VSCode, it's only when I call the function from Postman that the error surfaces. How do I run the dependency installation on Azure rather than building locally and uploading a zip? This is what VSCode seems to be doing via the Azure plugin.

Function dependencies:

"dependencies": {
  "@anzp/azure-function-multipart": "^3.1.0",
  "@tensorflow/tfjs-node": "^4.2.0"
},
"devDependencies": {
  "@azure/functions": "^3.0.0",
  "@types/node": "16.x",
  "azure-functions-core-tools": "^4.x",
  "typescript": "^4.0.0"
}

Output Error:

Result: Failure Exception: Worker was unable to load function predict: '/home/site/wwwroot/node_modules/@tensorflow/tfjs-node/lib/napi-v8/tfjs_binding.node: invalid ELF header' Stack: Error: Worker was unable to load function predict: '/home/site/wwwroot/node_modules/@tensorflow/tfjs-node/lib/napi-v8/tfjs_binding.node: invalid ELF header' at Object.Module._extensions..node (node:internal/modules/cjs/loader:1239:18) at Module.load (node:internal/modules/cjs/loader:1033:32) at Function.Module._load (node:internal/modules/cjs/loader:868:12) at Module.require (node:internal/modules/cjs/loader:1057:19) at Object.apply (/azure-functions-host/workers/node/dist/src/worker-bundle.js:2:42034) at require (node:internal/modules/cjs/helpers:103:18) at Object.<anonymous> (/home/site/wwwroot/node_modules/@tensorflow/tfjs-node/dist/index.js:72:16) at Module._compile (node:internal/modules/cjs/loader:1155:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10) at Module.load (node:internal/modules/cjs/loader:1033:32)

Upvotes: 1

Views: 162

Answers (1)

Mark
Mark

Reputation: 858

I fixed this by using a GitHub workflow to deploy the function rather than doing it via VS Code. This way I was able to build for Linux and the error disappeared.

Upvotes: 0

Related Questions