> For the complete documentation index, see [llms.txt](https://docs.acecloud.ai/knowledge-base/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.acecloud.ai/knowledge-base/functions/how-to-create-a-function-in-acecloud.md).

# How to Create a Function in AceCloud?

## **1. Overview**

AceCloud Functions is a serverless platform that allows users to create and manage functions using supported programming languages and configurable compute resources.

Users can configure function runtime, scaling, CPU, memory, ephemeral storage, environment variables, environment secrets, secret file mounts, execution timeout, and log retention.

AceCloud supports two function packaging options:

* **Code:** The platform builds uploaded or in-browser source code into an image.
* **Container Image:** Pulls a pre-built image by digest from a container registry.

Users can add or update source code through the built-in Editor or upload an archive when using the Code option.

## **2. Prerequisites**

Before creating a function, ensure that you have:

* Access to the AceCloud portal.
* Selected the required **Project** and **Region**.
* Identified any required environment variables and environment secrets. You can create secrets from **Functions → Secrets** or use the **+ New secret** option available in the function configuration.
* For the **Container Image** option, an available container registry and repository containing the required image.

## **3. Navigate to Functions**

1. Log in to the AceCloud portal.
2. Select the required **Project** and **Region**.
3. From the left navigation menu, open **Functions → Overview**.
4. Click **Create Function**.

The function configuration page opens.

## **4. Configure Function Details**

### **4.1 Select the Packaging Type**

Choose the required packaging option.

**Option A: Code**

Select **Code** when you want the platform to build your function source code into an image.

You can add source code later through the built-in Editor or upload an archive.

**Option B: Container Image**

Select **Container Image** when you want to use a pre-built image from a container registry.

After selecting this option:

1. Select or enter the required **Registry**, as available in the form.
2. Select the required **Repository** from the dropdown.
3. Use the refresh control beside the repository field if you need to refresh the available repositories.
4. Continue configuring the remaining function details.

Ensure that the required registry and repository are available before proceeding.

### **4.2 Enter the Function Name**

Enter a name for the function.

The function name must follow these rules:

* Use lowercase letters, numbers, and hyphens only.
* The name must start with a letter or number.
* The name must end with a letter or number.

For example, hello-world follows the supported naming format.

### **4.3 Select the Language and Version**

Select the required programming language and runtime version from the available dropdowns.

The options displayed depend on the platform's supported runtimes.

### **4.4 Add a Description**

Enter a brief description of your function.

For example:

Processes customer order notifications.

The description helps you identify the purpose of the function when you manage multiple functions.

## **5. Configure Scaling**

Expand the **Scaling** section to configure how your function scales based on incoming requests.

### **Min scale**

Enter the minimum number of function instances to maintain.

The value must be **0 or greater**.

For example:

Min scale: 0

Setting the minimum scale to 0 allows the function to scale down when there are no requests.

### **Max scale**

Enter the maximum number of instances that can run simultaneously.

The maximum value is **100**.

For example:

Max scale: 10

### **Concurrency**

Enter the maximum number of requests that a single function instance can process concurrently.

The maximum supported value is **10**.

For example:

Concurrency: 10

Configure the scaling values according to your expected request volume and application workload.

## **6. Configure Resource Details**

Expand the **Resource Details** section to configure the resources available to each function instance.

### **CPU**

Enter the CPU required by each function instance.

You can allocate between **32 millicores and 4 cores**.

For example:

CPU: 500 millicores

### **RAM**

Enter the memory required by each function instance.

You can allocate between **64 MB and 8 GB**.

Select **MB** or **GB** as the unit.

For example:

RAM: 512 MB

### **Ephemeral storage**

Enter the temporary disk space required by your function.

You can allocate between **128 MB and 10 GB**.

Select **MB** or **GB** as the unit.

For example:

Ephemeral storage: 512 MB

Use ephemeral storage for temporary files generated during function execution. Do not use it to store data that needs to persist after the function instance is removed.

## **7. Configure Environment Variables**

Use environment variables to provide configuration values to your function at runtime.

1. Expand **Environment Variables**.
2. Click **Add variable**.
3. Enter the required variable name and value.
4. Add additional variables as needed.

Example:

| **Name**         | **Value**  |
| ---------------- | ---------- |
| APPLICATION\_ENV | production |

This is an illustrative application configuration example, not a platform-reserved variable.

**Important:** The ACEFAAS\_ prefix is reserved by the platform. Do not use it for custom environment variable names.

**Note:** Do not store passwords, API keys, access tokens, or other sensitive information as plain environment variables. Use environment secrets for sensitive values.

## **8. Configure Environment Secrets**

Environment secrets allow sensitive values to be referenced as environment variables in a function.

### **8.1 Create an Environment Secret**

1. Open **Functions → Secrets** from the left navigation menu.
2. Click **Create secret**.
3. Enter a **Secret Name**.
4. Select the **ENV** secret type.
5. Under **Key-value pairs**, enter the required **Key** and **Value**.
6. Click **+ Add Variable** to add additional key-value pairs if required.
7. Click **Create secret**.

The secret appears in the Secrets list after successful creation.

You can also click **New secret** from the **Environment Secrets** section while configuring a function.

### **8.2 Attach the Secret to a Function**

1. Open the function creation or editing configuration.
2. Expand **Environment Secrets**.
3. Click **Add secret**.
4. Enter the **Env name** that the function will use to access the value.
5. Select the required secret from the **Secret** dropdown.
6. Select the corresponding **Key**.
7. Add additional mappings if required.

The function can access the mapped value through the configured environment variable name, using the environment-variable access method supported by its programming language.

**Security note:** Store sensitive values such as API keys, passwords, and access tokens in secrets rather than hard-coding them in source code.

## **9. Configure Secret File Mounts**

Secret File Mounts allow a file secret to be mounted into the function container at a specified path.

### **9.1 Create a File Secret**

1. Open **Functions → Secrets**.
2. Click **Create secret**.
3. Enter a **Secret Name**.
4. Select the **File** secret type.
5. Upload the required file. The interface supports .env and .txt files up to 100 KB.
6. Verify that the uploaded filename appears in the dialog.
7. Click **Create secret**.

Ensure that the required Secret Name and file are provided before creating the secret.

You can also click **New secret** from the **Secret File Mounts** section while configuring a function.

### **9.2 Attach the File Secret to a Function**

1. Open the function configuration.
2. Expand **Secret File Mounts**.
3. Click **Add secret**.
4. Select the required file secret from the **Secret** dropdown.
5. Enter the **Mount path** where the file should be made available inside the function container.
6. Add additional mounts if required.

The application must read the file from the configured mount path. Choose a path appropriate for the application and its runtime.

## **10. Configure Advanced Settings**

Expand **Advanced Settings** to configure the execution timeout and log retention.

### **10.1 Timeout**

The timeout specifies the maximum execution time allowed for one invocation.

* Allowed range: **1–900 seconds**.
* The configuration screen shows 60 seconds as the default example.

Set the timeout according to the expected execution duration of the function.

### **10.2 Log Retention**

Log retention specifies how long function logs are retained.

* Allowed range: **1–3 days**.
* The configuration screen shows 3 days as an example.

Choose a retention period that meets your troubleshooting and monitoring requirements.

## **11. Review the Configuration**

Review the configuration and pricing estimate displayed by the platform before creating the function.

Verify the following:

* Function name, packaging type, language, and runtime version.
* Registry and repository, if using Container Image.
* Scaling and concurrency settings.
* CPU, RAM, and ephemeral storage.
* Environment variables.
* Environment secret mappings.
* Secret file mounts.
* Timeout and log retention.
* Estimated charges.

Correct any incorrect settings before proceeding.

## **12. Create the Function**

After reviewing the configuration, click **Create Function**.

Once the operation completes, navigate to **Functions → Overview** to locate the function in the list.

The list displays information such as:

* Function name.
* Runtime.
* Applied versions.
* Latest version.
* Last updated timestamp.
* Available actions.

## **13. Add or Update Source Code**

1. Open the required function by clicking on function name.
2. Select the **Editor** tab.
3. Choose the required workflow:
4. **Write in browser:** Work with source files in the built-in editor.
5. **Upload archive:** Upload source code as an archive.
6. Use the file explorer to select or edit the available source files.
7. Review the code before saving or applying changes.

The editor provides options such as **Load from version**, **Save Draft**, and **Apply new version**.

* **Save Draft:** Saves the current source changes as a draft.
* **Apply new version:** Applies the source changes as a new function version.

Use the appropriate action depending on whether you are saving work in progress or applying a version.

## **14. View Function Details and Versions**

### **14.1 Overview Tab**

Open the function and select **Overview** to view its configuration.

The page can display:

* Runtime.
* Packaging type.
* Applied versions.
* Latest version.
* Endpoint.
* Shared egress IP.
* Scaling and resource settings.
* Timeout and log retention.

Some fields, such as endpoint or version information, may display --- when a value is not available. Do not assume that a version or endpoint has been created merely because the function appears in the list.

### **14.2 Versions Tab**

Open the **Versions** tab to manage function versions.

The table can display:

* Version.
* Status.
* Traffic.
* Created date.
* Updated date.
* Available actions.

The page provides version-management guidance for traffic splits, rollback, and deleting versions that are no longer needed. The table may show no records when no versions have been created.

### **14.3 Other Function Tabs**

Depending on the function and platform configuration, additional tabs include:

* **Test:** For testing the function.
* **Insights:** For viewing function insights.
* **Logs:** For viewing function logs.

Use these tabs to validate behavior and investigate execution issues.

## **15. Edit an Existing Function**

1. Navigate to **Functions → Overview**.
2. Locate the required function.
3. Open the three-dot **Actions** menu.
4. Select **Edit**.
5. Update the available configuration fields.
6. Review the configuration summary and pricing estimate.
7. Click **Update Function** to save the changes.

Please note that some settings may not be editable after the function has been created. Kindly refer to the available options on the Edit Function page when making changes.

## **16. Delete a Function**

Deleting a function permanently removes it and cannot be undone. Kindly verify the function name before proceeding with the deletion.

1. Navigate to **Functions → Overview**.
2. Locate the function to delete.
3. Open its three-dot **Actions** menu.
4. Select **Delete**.
5. Review the confirmation dialog and verify the function name.
6. Click **Delete** to confirm, or click **Cancel** to stop the operation.
