Terraform Error: updating Data Factory - Managed Virtual Network


While upgrading terraform azurerm provider from v2.6.4 to v2.81.0, terraform apply complained about the managed virtual network on Azure Data Factory.

Error: updating Data Factory: (Factory Name "adf-xxxx" / Resource Group "rg-xxxx"): once Managed Virtual Network has been Enabled it's not possible to disable it
│ 
│   with module.data_factory.azurerm_data_factory.data_factory_xxx,
│   on modules/data_factory/main.tf line 9, in resource "azurerm_data_factory" "data_factory_xxx":
│    9: resource "azurerm_data_factory" "data_factory_xxx" {

This happened because azurerm v2.81.0 is restaging the resource (data factory) with a new schema, and while doing so, the managed virtual network enabled outside of the terraform became an issue.

According to the error log, the terraform seems to disable the existing managed virtual network, while I want to leave it enabled. 

Fortunately, there was a managed_virtual_network_enabled parameter in this resource, so setting it to true fixed it as it stopped trying to disable the managed virtual network.

resource "azurerm_data_factory" "data_factory_xxx" {
name = var.data_factory_name
location = var.location
resource_group_name = var.resource_group_name
managed_virtual_network_enabled = true

...
}

Comments