Skip to content

Edit a function

View as Markdown

You can change a function after you create it: its code and requirements, its environment variables, and its system configuration. Saving your changes rebuilds and redeploys the function.

Open the function once it is Running or Failed. You can edit and save a failed function like any other. A function’s code, environment variables, and settings are read-only while it is Creating or Deploying.

In Compute > Functions, under Actions, click the pencil icon for the function. You can also click the function’s name. The function’s page opens with its code editor.

Edit the code and the requirements file in their tabs. You can also replace the code with a fresh ZIP in the upload area above the editor. See Upload code as a ZIP.

Add or change Environment variables in Function Configuration. See Use environment variables for the naming rules.

Open the System Configuration tab. There you can change:

  • Memory: 128, 256, 512, or 1024 MB.
  • Timeout (sec): the seconds a function can run, from 1 to 600.
  • Enable Dedicated Replica and Minimum Replica, for CPU and container functions. See Keep a function ready with dedicated replicas.

The function’s name, runtime, and hardware stay as you set them when you created it. To change any of them, create a new function. See Create a function.

Once you change the code, the environment variables, or the system configuration, the Try button above the editor becomes Save. On a Failed function, Save is available once you change something.

Click Save.

Saving rebuilds and redeploys the function. On the Python 3.11 (Http) sample, a saved edit takes about 15 seconds to redeploy.

A new function’s Version is 0, and the first saved edit makes it 1. Each later save raises it by one.

Select the function in the Functions list and open the Info tab below the list. Check that Version went up by one. Call the function again to confirm the new behaviour. See Call a function.

If the function fails after an edit, check its logs. See View logs and monitoring and Troubleshooting Functions.