diff --git a/azurerm/internal/services/web/app_service.go b/azurerm/internal/services/web/app_service.go index 97224e1cb5e6..5bd7e2cf32e5 100644 --- a/azurerm/internal/services/web/app_service.go +++ b/azurerm/internal/services/web/app_service.go @@ -421,10 +421,7 @@ func schemaAppServiceSiteConfig() *schema.Schema { string(web.ScmTypeOneDrive), string(web.ScmTypeTfs), string(web.ScmTypeVSO), - // Not in the specs, but is set by Azure Pipelines - // https://github.com/Microsoft/azure-pipelines-tasks/blob/master/Tasks/AzureRmWebAppDeploymentV4/operations/AzureAppServiceUtility.ts#L19 - // upstream issue: https://github.com/Azure/azure-rest-api-specs/issues/5345 - "VSTSRM", + string(web.ScmTypeVSTSRM), }, false), }, diff --git a/azurerm/internal/services/web/resource_arm_app_service.go b/azurerm/internal/services/web/resource_arm_app_service.go index a3570549f6c2..1d6166525f67 100644 --- a/azurerm/internal/services/web/resource_arm_app_service.go +++ b/azurerm/internal/services/web/resource_arm_app_service.go @@ -377,6 +377,8 @@ func resourceArmAppServiceUpdate(d *schema.ResourceData, meta interface{}) error // If `source_control` is defined, we need to set site_config.0.scm_type to "None" or we cannot update it _, hasSourceControl := d.GetOk("source_control.0.repo_url") + scmType := web.ScmTypeNone + if d.HasChange("site_config") || hasSourceControl { // update the main configuration siteConfig, err := expandAppServiceSiteConfig(d.Get("site_config")) @@ -387,8 +389,10 @@ func resourceArmAppServiceUpdate(d *schema.ResourceData, meta interface{}) error SiteConfig: siteConfig, } - if hasSourceControl { - siteConfigResource.SiteConfig.ScmType = "None" + scmType = siteConfig.ScmType + // ScmType being set blocks the update of source_control in _most_ cases, ADO is an exception + if hasSourceControl && scmType != web.ScmTypeVSTSRM { + siteConfigResource.SiteConfig.ScmType = web.ScmTypeNone } if _, err := client.CreateOrUpdateConfiguration(ctx, id.ResourceGroup, id.Name, siteConfigResource); err != nil { @@ -396,7 +400,8 @@ func resourceArmAppServiceUpdate(d *schema.ResourceData, meta interface{}) error } } - if hasSourceControl { + // Don't send source_control changes for ADO controlled Apps + if hasSourceControl && scmType != web.ScmTypeVSTSRM { sourceControlProperties := expandAppServiceSiteSourceControl(d) sourceControl := &web.SiteSourceControl{} sourceControl.SiteSourceControlProperties = sourceControlProperties diff --git a/azurerm/internal/services/web/resource_arm_function_app.go b/azurerm/internal/services/web/resource_arm_function_app.go index 062c519f0a94..f7a2b23f50cf 100644 --- a/azurerm/internal/services/web/resource_arm_function_app.go +++ b/azurerm/internal/services/web/resource_arm_function_app.go @@ -458,6 +458,8 @@ func resourceArmFunctionAppUpdate(d *schema.ResourceData, meta interface{}) erro // repo_url is required by the API _, hasSourceControl := d.GetOk("source_control.0.repo_url") + scmType := web.ScmTypeNone + if d.HasChange("site_config") || hasSourceControl { siteConfig, err := expandFunctionAppSiteConfig(d) if err != nil { @@ -467,8 +469,10 @@ func resourceArmFunctionAppUpdate(d *schema.ResourceData, meta interface{}) erro SiteConfig: &siteConfig, } - if hasSourceControl { - siteConfigResource.SiteConfig.ScmType = "None" + scmType = siteConfig.ScmType + // ScmType being set blocks the update of source_control in _most_ cases, ADO is an exception + if hasSourceControl && scmType != web.ScmTypeVSTSRM { + siteConfigResource.SiteConfig.ScmType = web.ScmTypeNone } if _, err := client.CreateOrUpdateConfiguration(ctx, id.ResourceGroup, id.Name, siteConfigResource); err != nil { @@ -476,7 +480,8 @@ func resourceArmFunctionAppUpdate(d *schema.ResourceData, meta interface{}) erro } } - if hasSourceControl { + // Don't send source_control changes for ADO controlled Apps + if hasSourceControl && scmType != web.ScmTypeVSTSRM { sourceControlProperties := expandAppServiceSiteSourceControl(d) sourceControl := &web.SiteSourceControl{} sourceControl.SiteSourceControlProperties = sourceControlProperties