# How to Install Scheduled Blocking

Azion **Scheduled Blocking** is a *serverless* integration available at Azion **Marketplace**.

This integration allows you to control the access to your application based on a time schedule, according to your needs.

---

## Getting the integration

To use the **Scheduled Blocking** integration provided by Azion Marketplace, you have to:

1. Access [Azion Console](/en/documentation/products/guides/how-to-access-azion-console/) > **Marketplace**.
2. On the Marketplace homepage, select **Scheduled Blocking** card.
3. Once the integration's page opens, click the **Install** button, at the bottom-right corner of the page.

You'll see a message indicating that your integration was successfully installed.

:::tip
You can search any integration by browsing through the cards, using the filters, or typing a keyword in the search bar.
:::

---

## Configuring the integration

### Setting up a firewall

To instantiate the **Scheduled Blocking** integration, follow the steps:

1. In the **Products menu**, select **Firewall** in the **SECURE** section.
2. Click the **+ Firewall** button.
3. Give an easy-to-remember name to your firewall.
4. Turn the **Functions** switch on.
5. Click the **Save** button.

Done. Now you've instantiated the firewall for your function.

### Setting up the integration

To instantiate the **Scheduled Blocking** integration, while still on the **Firewall** page:

1. Select the **Functions Instances** tab.
2. Click the **+ Function Instance** button.
3. Give an easy-to-remember name to your instance.
4. On the dropdown menu, select the **Scheduled Blocking** function.
  - This action will load the **Arguments** tab.

The **Arguments** tab will load a `JSON` file that looks like this:

```json
{
  "schedule": [
    {
      "action": "deny",
      "execute_action_when": "in_interval",
      "interval": {
        "starts_at_utc": "00:00",
        "finishes_at_utc": "00:59"
      },
      "week_days": {
        "Sun": true,
        "Mon": true,
        "Tue": true,
        "Wed": true,
        "Thu": true,
        "Fri": false,
        "Sat": true
      }
    },
    {
      "action": "drop",
      "execute_action_when": "not_in_interval",
      "interval": {
        "starts_at_utc": "01:00",
        "finishes_at_utc": "20:00"
      },
      "week_days": {
        "Mon": true,
        "Tue": true
      }
    },
    {
      "action": "static_response",
      "execute_action_when": "in_interval",
      "static_response_data": {
        "status": 503,
        "message": "You can write a custom message here",
        "html": "<!-- Some HTML can go here -->"
      },
      "interval": {
        "starts_at_utc": "20:00",
        "finishes_at_utc": "23:59"
      },
      "week_days": {
        "Sun": true,
        "Sat": true
      }
    }
  ]
}
```

The arguments that you can pass on this `JSON` file are the following:

| Atribute | Data Type | Description |
|---|---|---|
| `action`| String | Defines the action which the function will execute whenever a request matches the trigger criteria. <br /><br />Possible values are: <br />`Deny`: it will close the request with an HTTP 403 Forbidden response.<br />`Drop`: it will close the request without sending any response to the client.<br />`static_response`: it will close the request with a static response to it. |
| `execute_action_when` | String | Possible values are:<br />`in_interval`<br />`not_in_interval` <br /><br />When this argument is set to `in_interval`, the `action` will be executed whenever this function is called during the defined time interval.<br />When this argument is set to `not_in_interval`, the `action` will be executed whenever this function is called out of the defined time interval. |
| `interval` | Dictionary of Strings | Defines the time interval.<br />The values must be in the format "HH:MM", based on a 24 hour clock.<br />Note: This function is used in the UTC time zone. |
| `interval.starts_at_utc` | String | Defines the starting time of the interval. |
| `interval.finishes_at_utc` | String | Defines the ending time of the interval. |
| `week_days` | Dictionary of Booleans | Defines the days of the week when the function will be executed.<br />The indexes of the dictionary represent each day of the week. They are expected to use a 3 letter format (EEE), starting with capital case. If an invalid day is used, it'll be ignored.<br />Note that if a day is not present in the dictionary, it will be considered as `false`. |
| `static_response_data` | Dictionary of Strings | Allows the customization of the static response page which will be returned whenever the action is set to `static_response`. |
| `static_response_data.status` | Number | The status code used in the static response. |
| `static_response_data.message` | String | Allows you to customize the message displayed in the static response page. |
| `static_response_data.html` | String | Allows you to provide a custom HTML to be used when delivering the static response. |

:::note
For `static_response` parameter in `action`, you can define the status code that'll be used in the response, as well as set a custom HTML page that'll be delivered to your users.
:::

5. Click the **Save** button and you're done. Your Firewall integration is instantiated.

## Setting up the Rules Engine

Finally, you must set up the [Rules Engine](/en/documentation/products/secure/firewall/rules-engine/) to configure the *behavior* and the *criteria* to run the function.

Still in the **Firewall** page.

1. Select the **Rules Engine** tab.
2. Click the **+ Rule Engine** button.
3. Give a name to the rule.
4. Select a *criteria* to run and catch the domains that you want to run the integration on.
  - Example: if `Host` *matches* `yourdomain.com`.
5. Below, select a *behavior* to the *criteria*. In this case, it'll be **Run Function**. 
    - Select the adequate function according to the name you gave it during the instantiation step.
6. Click the **Save** button.

On the Console, you must now configure your domain so your firewall protects it.

7. On the **Products menu**, select **Workloads**.
8. Click on the domain you want to protect with your Scheduled Blocking function.
9. In the **Settings** section, click on the `Firewall` selector and choose the firewall you created.
10. Click the **Save** button.

Done. Now the Scheduled Blocking integration is running for every request made to the domain you indicated.

---