Azure / azure-functions-durable-js

JavaScript library for using the Durable Functions bindings
https://www.npmjs.com/package/durable-functions
MIT License
126 stars 46 forks source link

Functions not showing after deployment #599

Open krystofurr opened 2 months ago

krystofurr commented 2 months ago

Hi there,

I started working with durable functions for a project at work and I've ran into something that I'm having difficulty troubleshooting. It seems that my project builds and executes fine locally. It also has no issue deploying to Azure it seems. But depending on whether I comment out some of the source code in some of my custom modules that are imported into activity functions...the functions in Azure show up / don't show up. I'm at a loss as to what is causing it. Obviously it seems to me that it's my custom logic but it builds and run fine locally as I mentioned.

Durable Functions Version: 4

I have 1 orchestrator, 1 http trigger client and 1 activity. Inside of the activity function I have a class that imports azure dependencies. Some of which are these:

"@azure/identity": "^4.0.1", "@azure/storage-blob": "^12.17.0", "@azure/storage-blob-changefeed": "^12.0.0-preview.4", "@azure/storage-queue": "^12.16.0"

I've found if i comment out all of the logic in the class and just leave it as a skeleton basically, it deploys and shows the functions in Azure. Otherwise nothing shows. Files do get deployed because I've verified that the changes are in place. For deployment I'm using the following:

Is there anywhere in Azure Portal I can see if it's successfully recognized the durable function project and will post the functions under the 'Overview / Function Tab' in Azure ? It's a very strange issue

ejizba commented 2 months ago

Hi @krystofurr please take a look at these troubleshooting steps: https://learn.microsoft.com/en-us/azure/azure-functions/functions-node-troubleshoot?pivots=nodejs-model-v4

If the troubleshooting doc doesn't help, I have a few questions. Does the custom logic only have problems in Azure or does it work locally? It would be helpful to have some of your logs. If the problem reproduces locally, that would be the output of func host start. If it's only in Azure, you could either share the logs from app insights or give us your function app information with these instructions so that we can look at logs from our side

krystofurr commented 2 months ago

Thanks @ejizba for the response! It only has deployment problems in Azure. Seems to work fine locally when executing the client http trigger that initiates the orchestrator. I reviewed the links that you provided and here is some more insight into things.

As I mentioned above I have some other Azure dependencies...

"@azure/identity": "^4.0.1", "@azure/storage-blob": "^12.17.0", "@azure/storage-blob-changefeed": "^12.0.0-preview.4", "@azure/storage-queue": "^12.16.0"

So if I comment out anything that utilizes these dependencies in the project, it seems to fail finding the runtime and then switches to test mode. See the logs below when it fails to find any functions from the KUDU console...

2024-04-24T14:42:06.674 [Warning] WARNING: Failed to detect the Azure Functions runtime. Switching "@azure/functions" package to test mode - not all features are supported.
2024-04-24T14:42:06.683 [Warning] WARNING: Skipping call to register function "activityCheckUpdate" because the "@azure/functions" package is in test mode.
2024-04-24T14:42:06.691 [Warning] WARNING: Skipping call to register function "reportParserHttpStart" because the "@azure/functions" package is in test mode.
2024-04-24T14:42:06.692 [Warning] WARNING: Skipping call to register function "reportParserOrchestrator" because the "@azure/functions" package is in test mode.

2024-04-24T14:42:07.482 [Information] Reading functions metadata (Custom)
2024-04-24T14:42:07.723 [Information] 1 functions found (Custom)
2024-04-24T14:42:07.917 [Information] 0 functions loaded
2024-04-24T14:42:08.185 [Information] Generating 0 job function(s)
2024-04-24T14:42:08.325 [Warning] 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.

and logs when I uncomment lines that use those dependencies and they deploy. It finds the functions....

2024-04-24T14:43:46.780 [Information] Starting JobHost
2024-04-24T14:43:46.781 [Information] Starting Host (HostId=my-durable_function_app-dev, InstanceId=526cc336-f3bf-4b4e-8b5a-785fb2dd2d7a, Version=4.33.2.2, ProcessId=26, AppDomainId=1, InDebugMode=True, InDiagnosticMode=False, FunctionsExtensionVersion=~4)
2024-04-24T14:43:46.791 [Information] Loading functions metadata
2024-04-24T14:43:46.962 [Information] Reading functions metadata (Custom)
2024-04-24T14:43:47.051 [Information] 1 functions found (Custom)
2024-04-24T14:43:47.180 [Information] 3 functions loaded
2024-04-24T14:43:47.413 [Information] Generating 3 job function(s)
2024-04-24T14:43:47.475 [Information] Worker process started and initialized.
2024-04-24T14:43:47.715 [Information] Found the following functions:
Host.Functions.activityCheckUpdate
Host.Functions.reportParserHttpStart
Host.Functions.reportParserOrchestrator
ejizba commented 2 months ago

Okay this sounds like a known issue that was fixed a while ago. Check your package-lock.json file for the "require-in-the-middle" package and make sure it's at least v7.0.0. If not, update your dependencies until it is. Usually people don't rely on "require-in-the-middle" directly, so it can be a bit of a pain to figure out where the dependency is coming from. Our original reports of this issue (see here) were typically for people using the "applicationinsights" package, but there could be other packages depending on it, too.

krystofurr commented 2 months ago

I can also duplicate the issue outside of my own project by using a new generated durable function project through VS Code. Steps...

  1. In VSCode choose Azure Function: Create a function
  2. Choose your folder
  3. Choose 'Typescript'
  4. Model V4
  5. Durable Functions Orchestrator
  6. Azure Storage
  7. Name for your activity

Add the following dependency to your project

"@azure/storage-blob-changefeed": "^12.0.0-preview.4"

Try to instantiate a change feed client in the activity ( It won't actually get a client without credentials, but it just being there is enough to reproduce the issue )

new BlobChangeFeedClient(`https://myStorageAccountName.blob.core.windows.net`,null);

Deploy to Azure via pipeline. Used AzureFunctionApp@2 as 'runFromPackage' or 'zipDeploy'

Deploy is successful and no functions show in Azure

krystofurr commented 2 months ago

Okay this sounds like a known issue that was fixed a while ago. Check your package-lock.json file for the "require-in-the-middle" package and make sure it's at least v7.0.0. If not, update your dependencies until it is. Usually people don't rely on "require-in-the-middle" directly, so it can be a bit of a pain to figure out where the dependency is coming from. Our original reports of this issue (see here) were typically for people using the "applicationinsights" package, but there could be other packages depending on it, too.

I don't have this "require-in-the-middle" package in my package-lock.json. In my project or the generated one.

ejizba commented 2 months ago

It's really weird that this doesn't repro locally. Can you share your app name so I can look at logs from our side? Here are steps to share it privately: https://github.com/Azure/azure-functions-host/wiki/Sharing-Your-Function-App-name-privately

krystofurr commented 2 months ago

Unfortunately I can't share the app name. You can generate a blank application , go through the steps and try deploying it. That should provide the logs you need ?

ejizba commented 2 months ago

I tried your steps except deploying through VS Code and it worked just fine. This kind of error should be reproducible locally, so the fact that you can't do that makes me think it's a problem with your Azure Pipeline or the app itself in Azure

krystofurr commented 2 months ago

Well something worked today. A team member saw this in the logs

image

So the 'applicationinsights' dependency wasn't part of the project. After adding it ( ensuring that it was ^2.7.1 ) and redeploying, it deploys fine now. Any idea why ?

ejizba commented 2 months ago

I would double check to make sure you're committing your package-lock.json file to git (or yarn.lock if you're using yarn, etc.). These files should not be in your gitignore. Also in your pipeline, make sure you run npm ci instead of npm install (details on the differences here). I'm guessing your problem was a difference in dependencies in your local vs your pipeline, and these recommendations are designed to ensure they are the exact same.

krystofurr commented 2 months ago

Thanks for your help on this. Much appreciated.