diff --git a/internal/services/web/app_service_data_source.go b/internal/services/web/app_service_data_source.go index 6f6ecdd0f856..46801f5919c8 100644 --- a/internal/services/web/app_service_data_source.go +++ b/internal/services/web/app_service_data_source.go @@ -8,6 +8,8 @@ import ( "strings" "time" + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" @@ -212,7 +214,11 @@ func dataSourceAppServiceRead(d *pluginsdk.ResourceData, meta interface{}) error d.Set("location", location.NormalizeNilable(resp.Location)) if props := resp.SiteProperties; props != nil { - d.Set("app_service_plan_id", props.ServerFarmID) + servicePlan, err := commonids.ParseAppServicePlanIDInsensitively(pointer.From(props.ServerFarmID)) + if err != nil { + return err + } + d.Set("app_service_plan_id", servicePlan.ID()) d.Set("client_affinity_enabled", props.ClientAffinityEnabled) d.Set("enabled", props.Enabled) d.Set("https_only", props.HTTPSOnly) diff --git a/internal/services/web/app_service_resource.go b/internal/services/web/app_service_resource.go index 070c22859dab..811f7c9437b8 100644 --- a/internal/services/web/app_service_resource.go +++ b/internal/services/web/app_service_resource.go @@ -10,6 +10,7 @@ import ( "time" "github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-02-01/web" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" @@ -707,7 +708,11 @@ func resourceAppServiceRead(d *pluginsdk.ResourceData, meta interface{}) error { } if props := resp.SiteProperties; props != nil { - d.Set("app_service_plan_id", props.ServerFarmID) + servicePlan, err := commonids.ParseAppServicePlanIDInsensitively(pointer.From(props.ServerFarmID)) + if err != nil { + return err + } + d.Set("app_service_plan_id", servicePlan.ID()) d.Set("client_affinity_enabled", props.ClientAffinityEnabled) d.Set("enabled", props.Enabled) d.Set("https_only", props.HTTPSOnly) diff --git a/internal/services/web/app_service_slot_resource.go b/internal/services/web/app_service_slot_resource.go index f8d3cb7fb10a..5f41634d7931 100644 --- a/internal/services/web/app_service_slot_resource.go +++ b/internal/services/web/app_service_slot_resource.go @@ -9,6 +9,7 @@ import ( "time" "github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-02-01/web" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" @@ -481,7 +482,11 @@ func resourceAppServiceSlotRead(d *pluginsdk.ResourceData, meta interface{}) err } if props := resp.SiteProperties; props != nil { - d.Set("app_service_plan_id", props.ServerFarmID) + servicePlan, err := commonids.ParseAppServicePlanIDInsensitively(pointer.From(props.ServerFarmID)) + if err != nil { + return err + } + d.Set("app_service_plan_id", servicePlan.ID()) d.Set("client_affinity_enabled", props.ClientAffinityEnabled) d.Set("default_site_hostname", props.DefaultHostName) d.Set("enabled", props.Enabled) diff --git a/internal/services/web/function_app_data_source.go b/internal/services/web/function_app_data_source.go index b02e2b6d189e..97936adeec88 100644 --- a/internal/services/web/function_app_data_source.go +++ b/internal/services/web/function_app_data_source.go @@ -9,6 +9,8 @@ import ( "time" "github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-02-01/web" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" @@ -200,7 +202,11 @@ func dataSourceFunctionAppRead(d *pluginsdk.ResourceData, meta interface{}) erro d.Set("location", location.NormalizeNilable(resp.Location)) if props := resp.SiteProperties; props != nil { - d.Set("app_service_plan_id", props.ServerFarmID) + servicePlan, err := commonids.ParseAppServicePlanIDInsensitively(pointer.From(props.ServerFarmID)) + if err != nil { + return err + } + d.Set("app_service_plan_id", servicePlan.ID()) d.Set("enabled", props.Enabled) d.Set("default_hostname", props.DefaultHostName) d.Set("outbound_ip_addresses", props.OutboundIPAddresses) diff --git a/internal/services/web/function_app_resource.go b/internal/services/web/function_app_resource.go index c6ab97683fa5..7f5b08fe59e4 100644 --- a/internal/services/web/function_app_resource.go +++ b/internal/services/web/function_app_resource.go @@ -11,6 +11,7 @@ import ( "time" "github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-02-01/web" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" @@ -645,10 +646,11 @@ func resourceFunctionAppRead(d *pluginsdk.ResourceData, meta interface{}) error appServicePlanID := "" if props := resp.SiteProperties; props != nil { - if props.ServerFarmID != nil { - appServicePlanID = *props.ServerFarmID + servicePlan, err := commonids.ParseAppServicePlanIDInsensitively(pointer.From(props.ServerFarmID)) + if err != nil { + return err } - d.Set("app_service_plan_id", props.ServerFarmID) + d.Set("app_service_plan_id", servicePlan.ID()) d.Set("enabled", props.Enabled) d.Set("default_hostname", props.DefaultHostName) d.Set("https_only", props.HTTPSOnly) diff --git a/internal/services/web/function_app_slot_resource.go b/internal/services/web/function_app_slot_resource.go index cb5199b62c13..baaf28b8220c 100644 --- a/internal/services/web/function_app_slot_resource.go +++ b/internal/services/web/function_app_slot_resource.go @@ -12,6 +12,8 @@ import ( "github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-02-01/web" // nolint: staticcheck "github.com/google/uuid" + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" @@ -522,7 +524,11 @@ func resourceFunctionAppSlotRead(d *pluginsdk.ResourceData, meta interface{}) er } if props := resp.SiteProperties; props != nil { - d.Set("app_service_plan_id", props.ServerFarmID) + servicePlan, err := commonids.ParseAppServicePlanIDInsensitively(pointer.From(props.ServerFarmID)) + if err != nil { + return err + } + d.Set("app_service_plan_id", servicePlan.ID()) d.Set("enabled", props.Enabled) d.Set("default_hostname", props.DefaultHostName) d.Set("https_only", props.HTTPSOnly)