diff --git a/internal/services/network/subnet_resource.go b/internal/services/network/subnet_resource.go index 87824e25f966..a3c2343bc88c 100644 --- a/internal/services/network/subnet_resource.go +++ b/internal/services/network/subnet_resource.go @@ -290,6 +290,12 @@ func resourceSubnetUpdate(d *pluginsdk.ResourceData, meta interface{}) error { return err } + locks.ByName(id.VirtualNetworkName, VirtualNetworkResourceName) + defer locks.UnlockByName(id.VirtualNetworkName, VirtualNetworkResourceName) + + locks.ByName(id.Name, SubnetResourceName) + defer locks.UnlockByName(id.Name, SubnetResourceName) + existing, err := client.Get(ctx, id.ResourceGroup, id.VirtualNetworkName, id.Name, "") if err != nil { return fmt.Errorf("retrieving %s: %+v", *id, err) diff --git a/internal/services/network/subnet_resource_test.go b/internal/services/network/subnet_resource_test.go index 38c960bb3a54..0a55b22fc049 100644 --- a/internal/services/network/subnet_resource_test.go +++ b/internal/services/network/subnet_resource_test.go @@ -422,6 +422,13 @@ resource "azurerm_subnet" "test" { virtual_network_name = azurerm_virtual_network.test.name address_prefix = "10.0.2.0/24" } + +resource "azurerm_subnet" "test2" { + name = "internal2" + resource_group_name = azurerm_resource_group.test.name + virtual_network_name = azurerm_virtual_network.test.name + address_prefix = "10.0.3.0/24" +} `, r.template(data)) } @@ -571,6 +578,14 @@ resource "azurerm_subnet" "test" { address_prefix = "10.0.2.0/24" service_endpoints = ["Microsoft.Sql"] } + +resource "azurerm_subnet" "test2" { + name = "internal2" + resource_group_name = azurerm_resource_group.test.name + virtual_network_name = azurerm_virtual_network.test.name + address_prefix = "10.0.3.0/24" + service_endpoints = ["Microsoft.Sql"] +} `, r.template(data)) } @@ -585,6 +600,14 @@ resource "azurerm_subnet" "test" { address_prefix = "10.0.2.0/24" service_endpoints = ["Microsoft.Sql", "Microsoft.Storage"] } + +resource "azurerm_subnet" "test2" { + name = "internal2" + resource_group_name = azurerm_resource_group.test.name + virtual_network_name = azurerm_virtual_network.test.name + address_prefix = "10.0.3.0/24" + service_endpoints = ["Microsoft.Sql", "Microsoft.Storage"] +} `, r.template(data)) }