Question

How to get function activation result after migrating to an app?

Hi,

I have a function which I invoke by sending a HTTP request:

https://faas-lon1-123456.doserverless.co/api/v1/namespaces/fn-my-namespace/actions/foo/bar

This immediately returns without blocking and sends back a x-openwhisk-activation-id HTTP header. I then poll /api/v1/namespaces/fn-my-namespace/activations/{$id}/result until the result is ready. I then send a HTTP request to /api/v1/namespaces/fn-my-namespace/activations/{$id} to fetch metdata about the result (time spent and memory used).

I want to move these functions to the app platform so I can take advantage of automatic Github builds. The problem is I’m given a ondigitalocean.app subdomain which doesn’t seem to have the API endpoints I need. A request to my-application.ondigitalocean.app/foo/bar still gives me the x-openwhisk-activation-id header but I don’t know where to use the activation ID to get the result/metadata. Also with this URL the request is blocking until the function is finished and it seems wasteful to keep a HTTP connection open for up to 15 minutes.

Please let me know if what I’m trying to do is possible. It seems like it should be but I couldn’t find any documentation.

Thanks.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Matt Welke
DigitalOcean Employee
DigitalOcean Employee badge
May 15, 2023

It isn’t possible to retrieve the activation result for a function invocation when the function is deployed with App Platform. This is because the App Platform integration is meant to help with API use cases where instead of storing the result of the invocation and retrieving it later (asynchronous), the result of the invocation is meant to be used by the HTTP client immediately (synchronous). We also hide the namespace from you since for this use case, you wouldn’t need access to it (e.g. you’d do everything via App Platform, not doctl).

However, given what you wrote here, I think it does make sense. You chose App Platform not because you have this synchronous-only use case, but because you wanted your functions to be deployed automatically when changes are merged into your Git repo. And it’s true that standalone Functions doesn’t support this right now.

Here are a few workarounds I can suggest to you:

  1. Use a CI/CD service like GitHub Actions (you say you’re using GitHub) to run a workflow when changes are made to your Git repo to invoke doctl to deploy your functions. With this, you’re basically replicating the automatic deployments that App Platform does.

  2. Instead of returning the result of your operation from your function and then retrieving it as the activation result from the Functions system, store the result explicitly somewhere else, such as Spaces or one of our managed databases. Then, you can retrieve the operation result from the place you store it however works best for you.

If you’d like to get your feedback about your use case logged in our public feedback platform so that we can track it, feel free to do so with ideas.digitalocean.com.

Feel free to let us know if you have any other questions about using Functions or App Platform!

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel
Get started for free

Enter your email to get $200 in credit for your first 60 days with DigitalOcean.

New accounts only. By submitting your email you agree to our Privacy Policy.

© 2023 DigitalOcean, LLC.