Receiving a bad request - The application could not be found error when creating a Monitor Scheduled Query Rule via Terraform

Garrick Hensberg 0 Reputation points
2025-03-09T20:00:25.5066667+00:00

Hi All,

I am using Terraform to deploy my Azure resources. I have recently started receiving an error when deploying resources using azurerm_monitor_scheduled_query_rules_alert_v2.

I am getting the following error:

Error: creating or updating Monitor Scheduled Query Rule (Subscription: ""*

│ Resource Group Name: "xxx"

│ Scheduled Query Rule Name: "xxx-alert"): unexpected status 400 (400 Bad Request) with error: BadRequest: The application could not be found Activity ID: 4fcf2337-57c0-4228-9e89-c239bce70368.

This began happening on Friday (7th March) but was working fine the day before. Nothing has changed with this terraform resource configuration.

I used the same terraform configuration in another subscription and that subscription worked correctly and the alert was created.

I assume something is wrong with the subscription that I am getting this error on, but I have no idea what to look for to resolve the issue.

Any help in this regard would be very much appreciated.

Terraform used to create the resource:

`

resource "azurerm_monitor_scheduled_query_rules_alert_v2" "default" {
  name                = "xxx-alert"
  location            = var.region
  resource_group_name = var.resource_group_name

  action {
    action_groups = var.action_groups
  }

  scopes      = [var.data_source_id]
  description = var.description
  enabled     = var.enabled
  criteria {
    query                   = var.query
    operator                = var.operator
    threshold               = var.threshold
    time_aggregation_method = "Count"
  }
  severity             = var.severity
  evaluation_frequency = var.frequency
  window_duration      = var.time_window
}

`

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,502 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Boris Von Dahle 3,211 Reputation points
    2025-03-09T20:31:47.7833333+00:00

    Hello,

    The error that you receive : BadRequest: The application could not be found Activity ID: 4fcf2337-57c0-4228-9e89-c239bce70368. is likely to be due to incorrect permissions or inexistant application.

    Try to see if your app still exist or has the right privileges :

    az ad sp show --id <your-client-id>

    Regards

    Boris von Dahle


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.