Azure resource locks

Hello All,

I looking for the options to create a azure resource lock flow when I ran the workflow it should remove the existing lock and make modification on the resource then need to lock the resource again. tried all the corner no luck.

current code sometime not working perfectly locks are not removing so i want to make a separate workflow.

resource “random_id” “rng” {
keepers = {
id = “${timestamp()}”
byte_length = 8

resource “azurerm_management_lock” “lock_vnet” {
provider = azurerm.spoke

count = var.vnet_management_lock ? 1 : 0 # Conditionally deploy based on the boolean variable
name = “automatic lock ${random_id.rng.hex}”
scope =
lock_level = “ReadOnly”