Cannot create two certificate resources on app service

I’m trying to create two private key certificates (.pfx) for my App Service via Terraform using azurerm. I have created two resources, which are named “app_service_certificate” and “app_service_api_certificate”. The resource definitions are basically identical, however, app_service_certificate also has a custom hostname binding, whereas app_service_api_certificate does not.

Below are the resource definitions for each:

resource "azurerm_app_service_certificate" "app_service_certificate" {

  name                = local.certificate_name

  pfx_blob            = local.certificate_pfx_blob

  password            = local.certificate_password

  resource_group_name = azurerm_resource_group.resource_group.name

  location            = azurerm_resource_group.resource_group.location

  depends_on = [ azurerm_app_service.app_service ]

}

app_service_api_certificate:

resource "azurerm_app_service_certificate" "app_service_api_certificate" {

  name                = local.api_certificate_name

  pfx_blob            = local.api_certificate_pfx_blob

  password            = local.api_certificate_password

  resource_group_name = azurerm_resource_group.resource_group.name

  location            = azurerm_resource_group.resource_group.location

  depends_on = [ azurerm_app_service.app_service ]

}

When I run this release pipeline, app_service_certificate is created without issues (including the custom hostname binding). However, in the Terraform Apply task, the app_service_api_certificate resource does not get created. The console has “Still creating…” messages up until around 7 minutes, after which an error is displayed (I’m guessing due to timeout):

Error creating/updating App Service Certificate "my-api-certificate-name" (Resource Group "rg-name"): web.CertificatesClient#CreateOrUpdate: Failure responding to request: StatusCode=500 -- Original Error: autorest/azure: Service returned an error. Status=500 Code="" Message="An error has occurred."e[0m

Has anyone successfully added two certificates via Terraform? Appreciate any help, and happy to provide more information if needed.

Thanks