# Create & Configure a Function on Firewall

**Functions** are functions that run on the edge of the network, close to users. They can help you secure your applications through Firewall.

To use functions in your Firewall, you have to go through two steps:

- Create a function.
- Configure the behaviors on the Firewall page.

---

## Creating 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. In the **Code** tab, write your function code, or simply paste it.
    - The function being used on the firewall must contain a *finishing event*, such as:

```js 
    addEventListener("firewall", (event) => {
        event.deny();
    });
```

5. Save it.

Now, your function can be used on a firewall configuration.

---

## Configuring your function on the Firewall 

After creating a function, you need to configure the firewall to use it.

### 2.1 Creating a firewall

1. Access [Azion Console](/en/documentation/products/guides/how-to-access-azion-console/) > **Firewall**.
2. Click on **+ Firewall**.
3. Choose a name for the firewall.
4. Choose the domains you want to associate.
5. Enable the use of the **Functions** module.
6. Activate the firewall and save it.

After saving the configuration, on the same page, the tabs **Functions Instances** and **Rules Engine** become available.

### 2.2 Adding a function to the firewall

1. Go to the **Functions Instances** tab.
2. Click the **+ Function Instance** button.
3. Give a name to your function instance.
4. Choose a **Function**.
5. Click the **Save** button.
    - Only functions with the *Initiator Type* set as Firewall are listed.
6. Go to the **Rules Engine** tab.
7. Select **+ Rules Engine**.
8. Write a name for the new rule.
9. Configure the criteria that will be applied.
10. Set the behavior to **Run Function** and select the function you want to run.
11. Click the **Save** button.


:::note
It might take a while for your changes to propagate.
:::