Closed ChristianOConnor closed 1 month ago
Do you know what version of node you are running in the docker container? It should be version 19+ to support the globalThis.crypto
interface.
Do you know what version of node you are running in the docker container? It should be version 19+ to support the
globalThis.crypto
interface.
That fixed it! I was using node 18. I replaced FROM mcr.microsoft.com/azure-functions/node:4-node18
with FROM mcr.microsoft.com/azure-functions/node:4-node20
and it works now! Thanks!
I created an Azure function locally with the following commands in powershell: func init --worker-runtime node --language typescript --docker func new --name generateBitcoinAddress --template "HTTP trigger" This creates a boilerplate Azure function that looks like this:
I built it and deployed it on docker:
It works, I hit the API with Postman using this post request:
It printed: Hello, Chris! And I ran this locally without Docker as well:
To hit this local non-docker API, I altered my Postman command to use port 7071 instead of 8080 and it succeeded. Now is the weird part. I modified the code to do something more complex. I took this test from @cmdcode/tapscript, https://github.com/cmdruid/tapscript/blob/master/test/example/taproot/keyspend.test.ts and converted it into an Azure Function:
It worked perfectly when I ran it locally WITHOUT Docker...
Then in Postman, I did:
It worked and produced this output:
But when I took this working Azure Function, and tried to launch it in a docker container, it didn't work:
I noticed this line in the output of the docker run command that wasn't present in the boilerplate code docker run command output:
No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
So I already knew it would fail because no function is at the API endpoint. But just to make sure it would fail, I altered my Postman command for port 8080:
And it gave me a 404 error. So what is the problem? Why does my code work locally when I run it with func start, but doesn't work when I deploy it via Docker?