Question

Specifying the entrypoint in a DO Function

I want to specify the file name and function name as the entrypoint to my function. The docs are not very helpful here as they don’t provide any examples. Is this possible, and if so, how would it be done? I would also love some examples in general; I haven’t gotten my function to work when setting anyy value for the main config setting; any non-empty-string results in a variety of errors.


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.

alexdo
Site Moderator
Site Moderator badge
June 19, 2023

Hello @timmyichen

To specify a custom entry point for your function, you need to provide the handler configuration in your app.yaml file. The handler configuration should be in the format filename.functionname.

Here’s an example:

  1. services:
  2. my-service:
  3. functions:
  4. my-function:
  5. handler: myfile.myfunction

In this example, your custom function named myfunction should be contained within a file named myfile.py

If you’re still encountering errors, please double-check your app.yaml file and the function definition in your Python file. Make sure there are no typos or syntax errors.

For more information on working with apps and functions, you can check out our documentation here: https://docs.digitalocean.com/products/app-platform/how-to/manage-functions/

Hope that this helps!

Still not sure how the main config setting works, but I was able to get what I needed by editing my package.json’s main field.

Try DigitalOcean for free

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

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

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

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

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