--- title: "Create a function" description: "Create a Functions function in MyAccount by choosing hardware and a runtime, naming it, sizing memory and timeout, and writing or uploading code." content_type: "how-to" product: "functions" platform: "MyAccount" url: "/myaccount/functions/how-to/create-a-function/" topic: ["create"] relationships: {"requires":["/myaccount/functions/how-to/activate-functions/"]} --- # Create a function Create a function and get its own public HTTPS URL. You choose the hardware, a runtime, a name, and how much memory and time the function can use, then write the code. For help choosing the hardware and runtime, see [Runtimes and hardware](/myaccount/functions/concepts/runtimes-and-hardware/). ## Before you begin You need Functions activated. See [Activate Functions](/myaccount/functions/how-to/activate-functions/). ## Open Create Function 1. In MyAccount, open **Compute > Functions**. 2. Click **Create Function**. ## Choose hardware **Create Function** offers two choices, both on CPU hardware: - **CPU Functions** for code from a runtime template, such as an API, a webhook, or a data job. - **Custom Container Image** to deploy your own Docker image instead. Select **CPU Functions** unless you are bringing your own image. The hardware, runtime, and name stay as you set them on this form. To change them later, create a new function. ## Choose a runtime Pick a runtime template from the list. The runtimes available depend on the hardware you chose. **CPU Functions** offers Python, Node.js, Go, C#, and PHP runtimes. **Custom Container Image** offers one runtime, also named **Custom Container Image**. To set it up, see [Deploy a custom container image](/myaccount/functions/how-to/deploy-a-custom-container-image/). For the full list, see [Runtimes and hardware](/myaccount/functions/concepts/runtimes-and-hardware/). ## Name the function Enter a name in **Function Name**. A name uses lowercase letters, digits, and hyphens, up to 40 characters. It must start with a letter and end with a letter or digit. Each function in your account needs its own name, whatever its status, until you delete it. A taken name gets "Function with name {name} already exists", with your name in place of `{name}`. Choose a different name. A **Failed** function keeps its name until you delete it. To reuse that name, delete the failed function first. See [Function with name {name} already exists](/myaccount/functions/troubleshooting/functions/#function-with-name-name-already-exists). ## Write the code The editor opens with your runtime's code file and requirements file, one per tab. Keep the file names as they are. For the files each runtime uses, see [Runtimes and hardware](/myaccount/functions/concepts/runtimes-and-hardware/). Edit the code and the requirements file to fit what you want to run. To start from the sample code, leave the code as it is. You can replace it later in the editor. See [Edit a function](/myaccount/functions/how-to/edit-a-function/). Instead of typing code, you can upload a ZIP of your code in the upload area above the editor. See [Upload code as a ZIP](/myaccount/functions/how-to/upload-code-as-a-zip/). ## (Optional) Add environment variables In **Function Configuration**, add **Environment variables**, each with a **Key** and a **Value**. See [Use environment variables](/myaccount/functions/how-to/use-environment-variables/) for the naming rules and how your code reads them. ## Set the system configuration Under **System Configuration**, choose: - **Memory**: 128, 256, 512, or 1024 MB. The form defaults to 128 MB. Each memory choice comes with a share of a CPU. See [Runtimes and hardware](/myaccount/functions/concepts/runtimes-and-hardware/#how-much-cpu-each-memory-size-gets) for the amounts. - **Timeout (sec)**: the seconds a function can run before it is stopped, from 1 to 600. The form defaults to 15 seconds. - (Optional) **Enable Dedicated Replica**: for a CPU or container function, keep 1 to 5 instances always running to avoid cold starts. Set the count in **Minimum Replica**. See [Keep a function ready with dedicated replicas](/myaccount/functions/how-to/keep-a-function-ready-with-dedicated-replicas/). Start with the defaults, and raise them if the function runs out of memory or time. ## Create the function Click **Create**. The function builds and deploys, moving through **Creating** and **Deploying**, then **Running** or **Failed**. A new **Python 3.11 (Http)** function with the sample code and 128 MB reaches **Running** in about 30 seconds. When the function reads **Running**, it is ready. Its public HTTPS **URL** is shown on the function's page and in the **Info** tab. Call it next. See [Call a function](/myaccount/functions/how-to/call-a-function/). If the function reads **Failed**, see [Troubleshooting Functions](/myaccount/functions/troubleshooting/functions/).