Activate Functions, run a first Python function from the sample code, and call it over its public HTTPS URL. All you need is a MyAccount account. Functions is available in Delhi.
Once Functions is active, your account pays the CPU monthly minimum each month, however little you use. It includes 4,50,000 GB-seconds of CPU usage. For the amount, see E2E’s pricing page.
Activate Functions
Section titled “Activate Functions”Activate Functions once for your account, before your first function.
If your account is prepaid, activation charges the minimum to your prepaid balance. Make sure the balance covers it. With less, activation stops at “Credit are not sufficient.”
- In MyAccount, open Compute > Functions.
- Click Get Started, then click Activate.
You see “FaaS plan activated successfully.” and land on Create Function. For what activation gives you and charges, see Activate Functions.
Create a first function
Section titled “Create a first function”- On Create Function, select CPU Functions.
- In the runtime list, choose Python 3.11 (Http). The editor opens with the sample code for that runtime.
- Enter a name in Function Name, such as
my-first-function. A function name uses lowercase letters, digits, and hyphens. It must start with a letter and end with a letter or digit. - Leave Memory at the default of 128 MB.
- Click Create.
The function builds and deploys. Its status changes from Creating to Deploying, then to Running when it is ready. On the sample, this takes about 30 seconds. See Create a function.
Call the function
Section titled “Call the function”Every function has a public HTTPS URL. To copy it, select the function in the Functions list and open the Info tab below the list.
To call the function with a GET request, run curl on your own computer with the function’s URL:
curl https://<function-name>-<suffix>.serverless.e2enetworks.net/Replace the address with the URL MyAccount shows for your function. The sample returns HTTP 200 with a JSON body. The body holds the message “Hello World!”, the request’s method, path, query, and body. It also holds a context with functionName set to function and functionVersion set to $LATEST. To send a JSON body with POST, see Call a function.
You can also call the function from MyAccount:
- In the Functions list, click the function’s name to open its page.
- Click Try.
- In User Input, enter JSON arguments, then click Post Request.
The response appears in Output.
See the logs
Section titled “See the logs”- In Compute > Functions, select the function in the list.
- Below the list, open the Logs tab.
- Choose a Duration, such as the default of 5 minutes, and read the log lines the function produced.
The runtime logs include the function’s own output. See View logs and monitoring.
(Optional) Delete the function if you are only testing
Section titled “(Optional) Delete the function if you are only testing”If you are trying Functions and will not use the function again, delete it. Deleting a function removes its running service and its stored code for good.
- In the Functions list, under Actions, click the trash can icon for the function.
- In Confirm Delete Function, click Delete.
See Delete a function.
Functions stays active after you delete the function. The minimum applies for each month in which Functions is active. To stop the minimum for later months, delete every function and deactivate Functions. See Deactivate Functions.
What you have now
Section titled “What you have now”Functions is active on your account. You created a first Python function from the sample code, called it, and read its logs. To write your own code and environment variables, see Edit a function. For what Functions costs, see Billing.
If the function will not deploy or does not answer, see Troubleshooting Functions.