Not able to create Azure managed certificate for functions

I am trying to create custom domain for Azure function with below code:
resource “azurerm_app_service_custom_hostname_binding” “example” {
hostname = “
app_service_name =
resource_group_name =
resource “azurerm_app_service_managed_certificate” “example” {
custom_hostname_binding_id =

resource “azurerm_app_service_certificate_binding” “example” {
hostname_binding_id =
certificate_id =
ssl_state = “SniEnabled”

while creating azurerm_app_service_managed_certificate, i am getting error “Error: ID was missing the serverFarms element”

There is no serverFarm element in id of “azurerm_app_service_custom_hostname_binding”.

Am i missing something or there is some other way to work with functions to create custom domain.