bcrypt not a valid win 32 application on azure app service
Asked Answered
I

1

2

In order to do some image processing using the Node library, Sharp, I had to upgrade my node executable on Azure App Service to 64-bits. I did this by downloading the executable manually and then setting its path in IISNode.yml.

Unfortunately, when I start the app, it throws the following error:

Application has thrown an uncaught exception and is terminated: Error: %1 is not a valid Win32 application.

\\?\D:\home\site\wwwroot\node_modules\bcrypt\build\Release\bcrypt_lib.node
    at Error (native)
    at Object.Module._extensions..node (module.js:597:18)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Function.cls_wrapMethod [as _load] (D:\home\site\wwwroot\node_modules\newrelic\lib\shimmer.js:256:38)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at bindings (D:\home\site\wwwroot\node_modules\bindings\bindings.js:76:44)
    at Object.<anonymous> (D:\home\site\wwwroot\node_modules\bcrypt\bcrypt.js:3:35)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Function.cls_wrapMethod [as _load] (D:\home\site\wwwroot\node_modules\newrelic\lib\shimmer.js:256:38)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (D:\home\site\wwwroot\node_modules\bookshelf-bcrypt\index.js:5:14)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)

I'm building and deploying the application using the Appveyor CI system. Here's my the relevant portion of my appveyor.yml file:

install:
  - ps: Install-Product node $env:nodejs_version x64
  - SET CL=-DDELAYIMP_INSECURE_WRITABLE_HOOKS
  - npm i --loglevel=warn
  - npm prune --production
  - 7z a api.zip * -x!test -x!db -x!.git -xr!.* -x!README.md -x!nodemon.json -x!appveyor.yml | FIND /V "ing  "

You'll see that I'm building using a 64-bit version of Node.

On my Azure app service, I have the platform set to 64-bit.

Things I've tried:

  • Setting the platform to 32-bit on Azure
  • Blowing away node_modules/ on App Service

Thanks in advance!

Interpretation answered 23/11, 2016 at 22:1 Comment(0)
I
5

The default node.js executation applications on Azure Web Apps are all in 32bit. So it raises your issue. We can use the custom node.js runtime to achieve your requirement. Please try the following steps:

1, Put a 64bit node.exe executation application in your application, e.g. in a runtime folder.

2, Modify the iisnode.yml, set:

nodeProcessCommandLine: "D:\home\site\wwwroot\runtime\node.exe"

3, Deploy your entire application to Azure Web Apps.

Additionally, you can use the following code to verify that whether the node.js binary is x64 or not.

var http = require("http");

http.createServer(function (request, response) {
    response.writeHead(200, { "Content-Type": "text/plain" });
    response.write(require('os').arch());
    response.end();

}).listen(process.env.PORT);

Please let me know if this does not work.

Imprest answered 24/11, 2016 at 6:54 Comment(4)
Thanks for the quick reply!Interpretation
Where is iisnode.yml? Does this still apply to the 'beta 2' version of Azure Functions?Uniliteral
Do I literally just need top copy over node.exe and nothing else?Uniliteral
What About Linux Container ? How to do it for Linux version of app service ?Cribwork

© 2022 - 2024 — McMap. All rights reserved.