unable to edit backup time for terraform azure_backup_policy_vm

adm_javolpini 5 Reputation points
2025-03-13T20:55:14.64+00:00

I am running terraform azurerm backup tests and running into an odd syntax issue. I am starting with the hashicorp documented example and changing the time but azure comes back with an error: "Message="Parameter NO_PARAM in request is invalid."

hashicorp example: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/backup_policy_vm

Error:

│ Error: updating Backup Policy (Subscription: "xxxxxx-xxxx-xxxx-xxxxxxxxxx"

│ Resource Group Name: "vm-backup-test"

│ Vault Name: "backup-test-vault"

│ Backup Policy Name: "backup-test-vault-policy"): protectionpolicies.ProtectionPoliciesClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="UserErrorInvalidRequestParameter" Message="Parameter NO_PARAM in request is invalid. Please provide correct value for parameter NO_PARAM"

Here is the terraform. Aside from editing the resource group and recovery vault name, and changing the version to v2 (enhanced) this is an exact copy of the documented example from hashicorp:

If I change the time to anything other than 23:00, the error will generate. If I change any other details, such as timezone to America/New_York, it will error. The only parameters that will work are the ones shown below.

I have tried both with updating the policy, and with testing on a fresh deployment. In every case, if any parameters are even slightly changed (such as time from 23:00 to 22:00 or 23:30), it will error.

I have researched and tested repeatedly but not finding any resolution. Is there some trick to get this working? Or is there an issue/bug with azurerm 4.0+?

Is there any logging/debugging on the backup vault that would help narrow down the error for more granular tracing? In terraform trace debug it only shows the http 400 error but no further explanation or details for the cause of the error.

Currently I am testing on azurerm provider 4.2.2. provider details are below.

resource "azurerm_backup_policy_vm" "backup_test_policy" {
  name                = "backup-test-vault-policy"
  resource_group_name = var.resource_group_name
  recovery_vault_name = azurerm_recovery_services_vault.backup_test_vault.name
  policy_type         = "V2"
  timezone            = "UTC"

  backup {
    frequency = "Daily"
    time      = "23:00"
   
  }

  retention_daily {
    count = 10
  }

  retention_weekly {
    count    = 42
    weekdays = ["Sunday", "Wednesday", "Friday", "Saturday"]
  }

  retention_monthly {
    count    = 7
    
    weekdays = ["Sunday", "Wednesday"]
    weeks    = ["First", "Last"]
    
 }

  retention_yearly {
    count    = 77
    
    weekdays = ["Sunday"]
    weeks    = ["Last"]
    months   = ["January"]
  }
}


terraform {
  required_providers {
    azapi = {
      source  = "azure/azapi"
      version = "~> 1.8"
    }
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 4.0"
    }
  }
}

provider "azapi" {
  default_location = "eastus"
}

provider "azurerm" {
  subscription_id = var.subscription_id
  features {}
}
Azure Backup
Azure Backup
An Azure backup service that provides built-in management at scale.
1,496 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ashok Gandhi Kotnana 10,350 Reputation points Microsoft External Staff Moderator
    2025-03-19T12:26:41.51+00:00

    Hi @adm_javolpini

    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to "Accept " the answer.

    Issue:

    unable to edit backup time for terraform azure_backup_policy_vm

    Solution:

    remove variable wouldn't function within this block

    If you have any other questions or are still running into more issues, please let me know. Thank you again for your time and patience throughout this issue.

    Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution.

    https://learn.microsoft.com/en-us/answers/support/accept-answer#why-only-one-accepted-answer

    1 person found this answer helpful.

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.