From cc1facb8b42fcb82aca976339929b3717f323ec1 Mon Sep 17 00:00:00 2001 From: Paul Knopf Date: Mon, 29 Apr 2024 10:49:42 -0400 Subject: [PATCH] Update various files to not set SiteConfig.PublicNetworkAccess. Latest Azure API changes throws errors if this setting is present in both locations: performing CreateOrUpdate: unexpected status 400 (400 Bad Request) with response: {"Code":"BadRequest","Message":"There was a conflict. SiteConfig.PublicNetworkAccess cannot be modified. Please modify the Site.PublicNetworkAccess property.","Target":null,"Details":[{"Message":"There was a conflict. SiteConfig.PublicNetworkAccess cannot be modified. Please modify the Site.PublicNetworkAccess property."},{"Code":"BadRequest"},{"ErrorEntity":{"ExtendedCode":"01020","MessageTemplate":"There was a conflict. {0}","Parameters":["SiteConfig.PublicNetworkAccess cannot be modified. Please modify the Site.PublicNetworkAccess property."],"Code":"BadRequest","Message":"There was a conflict. SiteConfig.PublicNetworkAccess cannot be modified. Please modify the Site.PublicNetworkAccess property."}}],"Innererror":null} --- internal/services/appservice/linux_function_app_resource.go | 6 +----- .../services/appservice/linux_function_app_slot_resource.go | 6 +----- internal/services/appservice/linux_web_app_resource.go | 6 +----- internal/services/appservice/linux_web_app_slot_resource.go | 6 +----- .../services/appservice/windows_function_app_resource.go | 6 +----- .../appservice/windows_function_app_slot_resource.go | 6 +----- internal/services/appservice/windows_web_app_resource.go | 6 +----- .../services/appservice/windows_web_app_slot_resource.go | 6 +----- 8 files changed, 8 insertions(+), 40 deletions(-) diff --git a/internal/services/appservice/linux_function_app_resource.go b/internal/services/appservice/linux_function_app_resource.go index 0403d7a2c6cf..6f6bda11115f 100644 --- a/internal/services/appservice/linux_function_app_resource.go +++ b/internal/services/appservice/linux_function_app_resource.go @@ -531,10 +531,8 @@ func (r LinuxFunctionAppResource) Create() sdk.ResourceFunc { pna = helpers.PublicNetworkAccessDisabled } - // (@jackofallops) - Values appear to need to be set in both SiteProperties and SiteConfig for now? https://github.com/Azure/azure-rest-api-specs/issues/24681 siteEnvelope.Properties.PublicNetworkAccess = pointer.To(pna) - siteEnvelope.Properties.SiteConfig.PublicNetworkAccess = siteEnvelope.Properties.PublicNetworkAccess - + if functionApp.KeyVaultReferenceIdentityID != "" { siteEnvelope.Properties.KeyVaultReferenceIdentity = pointer.To(functionApp.KeyVaultReferenceIdentityID) } @@ -1039,9 +1037,7 @@ func (r LinuxFunctionAppResource) Update() sdk.ResourceFunc { pna = helpers.PublicNetworkAccessDisabled } - // (@jackofallops) - Values appear to need to be set in both SiteProperties and SiteConfig for now? https://github.com/Azure/azure-rest-api-specs/issues/24681 model.Properties.PublicNetworkAccess = pointer.To(pna) - model.Properties.SiteConfig.PublicNetworkAccess = model.Properties.PublicNetworkAccess } if err := client.CreateOrUpdateThenPoll(ctx, *id, model); err != nil { diff --git a/internal/services/appservice/linux_function_app_slot_resource.go b/internal/services/appservice/linux_function_app_slot_resource.go index ce8366142a5f..4a8cae62d4fd 100644 --- a/internal/services/appservice/linux_function_app_slot_resource.go +++ b/internal/services/appservice/linux_function_app_slot_resource.go @@ -525,10 +525,8 @@ func (r LinuxFunctionAppSlotResource) Create() sdk.ResourceFunc { pan = helpers.PublicNetworkAccessDisabled } - // (@jackofallops) - Value appear to need to be set in both SiteProperties and SiteConfig for now? https://github.com/Azure/azure-rest-api-specs/issues/24681 siteEnvelope.Properties.PublicNetworkAccess = pointer.To(pan) - siteEnvelope.Properties.SiteConfig.PublicNetworkAccess = siteEnvelope.Properties.PublicNetworkAccess - + if functionAppSlot.KeyVaultReferenceIdentityID != "" { siteEnvelope.Properties.KeyVaultReferenceIdentity = pointer.To(functionAppSlot.KeyVaultReferenceIdentityID) } @@ -984,9 +982,7 @@ func (r LinuxFunctionAppSlotResource) Update() sdk.ResourceFunc { pan = helpers.PublicNetworkAccessDisabled } - // (@jackofallops) - Values appear to need to be set in both SiteProperties and SiteConfig for now? https://github.com/Azure/azure-rest-api-specs/issues/24681 model.Properties.PublicNetworkAccess = pointer.To(pan) - model.Properties.SiteConfig.PublicNetworkAccess = model.Properties.PublicNetworkAccess } if err := client.CreateOrUpdateSlotThenPoll(ctx, *id, model); err != nil { diff --git a/internal/services/appservice/linux_web_app_resource.go b/internal/services/appservice/linux_web_app_resource.go index 050d2e0460e9..4a485d30b938 100644 --- a/internal/services/appservice/linux_web_app_resource.go +++ b/internal/services/appservice/linux_web_app_resource.go @@ -380,10 +380,8 @@ func (r LinuxWebAppResource) Create() sdk.ResourceFunc { pna = helpers.PublicNetworkAccessDisabled } - // (@jackofallops) - Values appear to need to be set in both SiteProperties and SiteConfig for now? https://github.com/Azure/azure-rest-api-specs/issues/24681 siteEnvelope.Properties.PublicNetworkAccess = pointer.To(pna) - siteEnvelope.Properties.SiteConfig.PublicNetworkAccess = siteEnvelope.Properties.PublicNetworkAccess - + if webApp.VirtualNetworkSubnetID != "" { siteEnvelope.Properties.VirtualNetworkSubnetId = pointer.To(webApp.VirtualNetworkSubnetID) } @@ -825,9 +823,7 @@ func (r LinuxWebAppResource) Update() sdk.ResourceFunc { pna = helpers.PublicNetworkAccessDisabled } - // (@jackofallops) - Values appear to need to be set in both SiteProperties and SiteConfig for now? https://github.com/Azure/azure-rest-api-specs/issues/24681 model.Properties.PublicNetworkAccess = pointer.To(pna) - model.Properties.SiteConfig.PublicNetworkAccess = model.Properties.PublicNetworkAccess } if metadata.ResourceData.HasChange("virtual_network_subnet_id") { diff --git a/internal/services/appservice/linux_web_app_slot_resource.go b/internal/services/appservice/linux_web_app_slot_resource.go index c04c11064012..7941b3691137 100644 --- a/internal/services/appservice/linux_web_app_slot_resource.go +++ b/internal/services/appservice/linux_web_app_slot_resource.go @@ -361,10 +361,8 @@ func (r LinuxWebAppSlotResource) Create() sdk.ResourceFunc { pna = helpers.PublicNetworkAccessDisabled } - // (@jackofallops) - Values appear to need to be set in both SiteProperties and SiteConfig for now? https://github.com/Azure/azure-rest-api-specs/issues/24681 siteEnvelope.Properties.PublicNetworkAccess = pointer.To(pna) - siteEnvelope.Properties.SiteConfig.PublicNetworkAccess = siteEnvelope.Properties.PublicNetworkAccess - + if webAppSlot.VirtualNetworkSubnetID != "" { siteEnvelope.Properties.VirtualNetworkSubnetId = pointer.To(webAppSlot.VirtualNetworkSubnetID) } @@ -816,9 +814,7 @@ func (r LinuxWebAppSlotResource) Update() sdk.ResourceFunc { pna = helpers.PublicNetworkAccessDisabled } - // (@jackofallops) - Values appear to need to be set in both SiteProperties and SiteConfig for now? https://github.com/Azure/azure-rest-api-specs/issues/24681 model.Properties.PublicNetworkAccess = pointer.To(pna) - model.Properties.SiteConfig.PublicNetworkAccess = model.Properties.PublicNetworkAccess } if metadata.ResourceData.HasChange("virtual_network_subnet_id") { diff --git a/internal/services/appservice/windows_function_app_resource.go b/internal/services/appservice/windows_function_app_resource.go index 384b5b106a89..b4fb0c97fbf0 100644 --- a/internal/services/appservice/windows_function_app_resource.go +++ b/internal/services/appservice/windows_function_app_resource.go @@ -532,10 +532,8 @@ func (r WindowsFunctionAppResource) Create() sdk.ResourceFunc { pna = helpers.PublicNetworkAccessDisabled } - // (@jackofallops) - Values appear to need to be set in both SiteProperties and SiteConfig for now? https://github.com/Azure/azure-rest-api-specs/issues/24681 siteEnvelope.Properties.PublicNetworkAccess = pointer.To(pna) - siteEnvelope.Properties.SiteConfig.PublicNetworkAccess = siteEnvelope.Properties.PublicNetworkAccess - + if functionApp.VirtualNetworkSubnetID != "" { siteEnvelope.Properties.VirtualNetworkSubnetId = pointer.To(functionApp.VirtualNetworkSubnetID) } @@ -1055,9 +1053,7 @@ func (r WindowsFunctionAppResource) Update() sdk.ResourceFunc { pna = helpers.PublicNetworkAccessDisabled } - // (@jackofallops) - Values appear to need to be set in both SiteProperties and SiteConfig for now? https://github.com/Azure/azure-rest-api-specs/issues/24681 model.Properties.PublicNetworkAccess = pointer.To(pna) - model.Properties.SiteConfig.PublicNetworkAccess = model.Properties.PublicNetworkAccess } if err := client.CreateOrUpdateThenPoll(ctx, *id, model); err != nil { diff --git a/internal/services/appservice/windows_function_app_slot_resource.go b/internal/services/appservice/windows_function_app_slot_resource.go index 1d1e85ad2672..232168e67280 100644 --- a/internal/services/appservice/windows_function_app_slot_resource.go +++ b/internal/services/appservice/windows_function_app_slot_resource.go @@ -542,10 +542,8 @@ func (r WindowsFunctionAppSlotResource) Create() sdk.ResourceFunc { pna = helpers.PublicNetworkAccessDisabled } - // (@jackofallops) - Values appear to need to be set in both SiteProperties and SiteConfig for now? https://github.com/Azure/azure-rest-api-specs/issues/24681 siteEnvelope.Properties.PublicNetworkAccess = pointer.To(pna) - siteEnvelope.Properties.SiteConfig.PublicNetworkAccess = siteEnvelope.Properties.PublicNetworkAccess - + if functionAppSlot.VirtualNetworkSubnetID != "" { siteEnvelope.Properties.VirtualNetworkSubnetId = pointer.To(functionAppSlot.VirtualNetworkSubnetID) } @@ -1000,9 +998,7 @@ func (r WindowsFunctionAppSlotResource) Update() sdk.ResourceFunc { pna = helpers.PublicNetworkAccessDisabled } - // (@jackofallops) - Values appear to need to be set in both SiteProperties and SiteConfig for now? https://github.com/Azure/azure-rest-api-specs/issues/24681 model.Properties.PublicNetworkAccess = pointer.To(pna) - model.Properties.SiteConfig.PublicNetworkAccess = model.Properties.PublicNetworkAccess } if err = client.CreateOrUpdateSlotThenPoll(ctx, *id, model); err != nil { diff --git a/internal/services/appservice/windows_web_app_resource.go b/internal/services/appservice/windows_web_app_resource.go index a6324f19c336..e1f1e048df26 100644 --- a/internal/services/appservice/windows_web_app_resource.go +++ b/internal/services/appservice/windows_web_app_resource.go @@ -385,10 +385,8 @@ func (r WindowsWebAppResource) Create() sdk.ResourceFunc { pna = helpers.PublicNetworkAccessDisabled } - // (@jackofallops) - Values appear to need to be set in both SiteProperties and SiteConfig for now? https://github.com/Azure/azure-rest-api-specs/issues/24681 siteEnvelope.Properties.PublicNetworkAccess = pointer.To(pna) - siteEnvelope.Properties.SiteConfig.PublicNetworkAccess = siteEnvelope.Properties.PublicNetworkAccess - + if webApp.KeyVaultReferenceIdentityID != "" { siteEnvelope.Properties.KeyVaultReferenceIdentity = pointer.To(webApp.KeyVaultReferenceIdentityID) } @@ -891,9 +889,7 @@ func (r WindowsWebAppResource) Update() sdk.ResourceFunc { pna = helpers.PublicNetworkAccessDisabled } - // (@jackofallops) - Values appear to need to be set in both SiteProperties and SiteConfig for now? https://github.com/Azure/azure-rest-api-specs/issues/24681 model.Properties.PublicNetworkAccess = pointer.To(pna) - model.Properties.SiteConfig.PublicNetworkAccess = model.Properties.PublicNetworkAccess } if err = client.CreateOrUpdateThenPoll(ctx, *id, model); err != nil { diff --git a/internal/services/appservice/windows_web_app_slot_resource.go b/internal/services/appservice/windows_web_app_slot_resource.go index f3d490162576..a63a17ff3c0d 100644 --- a/internal/services/appservice/windows_web_app_slot_resource.go +++ b/internal/services/appservice/windows_web_app_slot_resource.go @@ -364,10 +364,8 @@ func (r WindowsWebAppSlotResource) Create() sdk.ResourceFunc { pna = helpers.PublicNetworkAccessDisabled } - // (@jackofallops) - Values appear to need to be set in both SiteProperties and SiteConfig for now? https://github.com/Azure/azure-rest-api-specs/issues/24681 siteEnvelope.Properties.PublicNetworkAccess = pointer.To(pna) - siteEnvelope.Properties.SiteConfig.PublicNetworkAccess = siteEnvelope.Properties.PublicNetworkAccess - + if webAppSlot.KeyVaultReferenceIdentityID != "" { siteEnvelope.Properties.KeyVaultReferenceIdentity = pointer.To(webAppSlot.KeyVaultReferenceIdentityID) } @@ -857,9 +855,7 @@ func (r WindowsWebAppSlotResource) Update() sdk.ResourceFunc { pna = helpers.PublicNetworkAccessDisabled } - // (@jackofallops) - Values appear to need to be set in both SiteProperties and SiteConfig for now? https://github.com/Azure/azure-rest-api-specs/issues/24681 model.Properties.PublicNetworkAccess = pointer.To(pna) - model.Properties.SiteConfig.PublicNetworkAccess = model.Properties.PublicNetworkAccess } if metadata.ResourceData.HasChange("virtual_network_subnet_id") {