---
id: SAIFTRBL0008
moved_from:
  - guides/troubleshooting/function-app-service-plan-id-required.md
title: "Function App deploy fails: service_plan_id is required"
description: The event subscriber's Function App fails terraform plan with a missing required argument because the team's opt-in Elastic Premium Functions plan was never enabled.
tags:
  - troubleshooting
  - terraform
---

# Function App deploy fails: `service_plan_id` is required

**One-sentence summary:** `saif-event-subscriber-service` needs your team's opt-in Elastic Premium `-functions` App Service plan, and until the platform team enables it the plan ID is `null`, so Terraform rejects the Function App with a missing-required-argument error.

---

## 🚨 Symptom

Deploying `saif-event-subscriber-service` fails during `terraform plan` (or `terraform apply`) with:

```text
Error: Missing required argument

  with module.function_app.azurerm_linux_function_app.this,
  on .terraform/modules/function_app/modules/functionapp_linux/main.tf line 5, in resource "azurerm_linux_function_app" "this":
   5:   service_plan_id               = var.service_plan_id

The argument "service_plan_id" is required, but no definition was found.
```

The error points at the third-party `functionapp_linux` module rather than at your service, so it reads like a module bug. It isn't — the plan ID your service passed in was `null`. Line numbers shift between `functionapp_linux` versions; the resource address and the `service_plan_id` wording stay the same.

This appears in the event subscriber's Deploy pipeline Terraform step, and locally when running Terraform against the service.

---

## 📌 Applies to

| Aspect | Value |
| ------ | ----- |
| **Component** | Terraform — `saif-event-subscriber-service` |
| **Module versions** | `functionapp_linux ~> 5.1.1`; `saif-resources //modules/environment` |
| **Related versions** | Check the [version compatibility matrix](../reference/version-compatibility.md) |

---

## 🧠 Cause

The Elastic Premium (EP) plan that Function Apps run on is **opt-in per team**, because EP plans bill even when idle. Teams that have never deployed a Function App don't have one.

`saif-event-subscriber-service` reads the plan from `module.environment.context.team_services.function_app_service_plan_id`, which the environment module resolves as `null` when the team hasn't enabled it. That `null` flows into `functionapp_linux`'s `service_plan_id`, which is a plain `string` variable with no null check, so it reaches `azurerm_linux_function_app` — where the `azurerm` provider requires it. Terraform blocks the plan there.

Nothing is misconfigured in your service. The prerequisite just isn't provisioned yet.

---

## ✅ Fix

The plan lives in the platform-owned `cloud-foundations` repo, so request it rather than changing your service:

1. Ask the platform team to enable your team's Function App service plan, through either channel:

    - [Platform Support Teams channel](https://teams.microsoft.com/l/channel/19%3Acb611810fb0b42b080cfff5590bdd51c%40thread.tacv2/Support?groupId=514d2dac-2d62-48ce-bf99-0fa0ce39469c&tenantId=a86cb8ed-369b-4df5-ace5-43811f6e08cf)
    - An issue in [saif-corp/cloud-foundations](https://github.com/saif-corp/cloud-foundations/issues)

2. Include in the request:

    - Your team name
    - The environments you need it in (test, qa, uat, prod)
    - That this is the opt-in Elastic Premium `-functions` plan, needed for `saif-event-subscriber-service`
    - Why the workload needs it, since EP plans carry a standing cost

3. Wait for confirmation that the team stack has been applied, then re-run the deploy.

On the platform side this enables the `-functions` plan for your team and creates a Linux Elastic Premium plan named `<team-service-plan>-functions` with elastic scaling. You don't make this change yourself, and you don't need to modify your service's Terraform.

---

## 🔬 Verify

After the team stack is applied, re-run `terraform plan` for the service. The `Missing required argument` error is gone and the plan shows the Function App to add:

```text
# module.function_app.azurerm_linux_function_app.this will be created
+ resource "azurerm_linux_function_app" "this" {
    + service_plan_id = "/subscriptions/.../providers/Microsoft.Web/serverfarms/<team-service-plan>-functions"
```

You can also confirm the plan exists in your team's resource group in the Azure portal: an App Service plan whose name ends in `-functions` with an EP SKU.

---

## 📚 Related

- [Event Subscriptions guide](../build/eventing/event-subscription.md)
- [Environment module README](https://github.com/saif-corp/forge/blob/main/src/terraform/saif-resources/modules/environment/README.md) — the `team_services.function_app_service_plan_id` contract
- [saif-corp/forge#1096](https://github.com/saif-corp/forge/issues/1096) — source issue
