# How to run serverless functions on Azion

import DocButton from '~/components/webkit/DocButton.vue';

[Functions](/en/documentation/products/build/applications/functions/) is a module of the Azion Web Platform that allows you to program and execute serverless functions.

<DocButton href="/en/documentation/products/build/applications/functions-instances/" label="Go to Functions for Applications reference" kind="secondary" size="medium" />

To run a function, you must:

- Create your own function or use any of those already available on [Azion Marketplace](https://console.azion.com/marketplace).
- Instantiate a function in an application.
- Define activation triggers within [Rules Engine](/en/documentation/products/build/applications/rules-engine/).

---

## Creating a new function

To create a function:

1. Access [Azion Console](/en/documentation/products/guides/how-to-access-azion-console/) > **Functions**.
2. Click on **+ Function**.
3. Choose a name for your function.
4. Write your code.
5. Click the **Save** button.


:::tip
Check the guide on [How to build an API with Functions and ChatGPT](/en/documentation/products/guides/edge-functions/api-builder/) for an example of a function you can run in your application. 
:::

---

## Instantiating a function

To demonstrate how to instantiate and run a function on an application, this guide will use the pre-configured **Azion - Hello World** function. To instantiate a function on an application:

1. Access [Azion Console](/en/documentation/products/guides/how-to-access-azion-console/) > **Applications**.
2. Click on the application to which you want to add a function.
3. Go to the **Functions Instances** tab.
4. Click **+ Function Instance**.
5. Name your function instance. For example: `Hello World function`.
6. Select the **Azion - Hello World** function.
7. Click the **Save** button.


---

## Configuring function activation criteria

1. In the same application, go to the **Rules Engine** tab.
2. Click **+ Rule**.
3. Give your rule a name.
4. Select **Request Phase**.
5. In the **Criteria** section, select:
    - If `${uri}` is equal `/hello-world`.
6. In the **Behaviors** section, choose **Run Function**.
7. Select the **Hello World function**
8. Click **Save**. 

Wait a few minutes for the propagation to be completed. 

To see your instanced function, access your application using its domain and the URI set in the rule, which is in the format `xxxxxxxxx.map.azionedge.net/hello-world`.

Now you've successfully configured and instantiated a function in an application.