I am trying to import operations from Azure Function into API Management API. Able to add a backend tagged to Azure Resource (Azure Function). But when adding the API from Azure Function, terraform code is not adding operations defined inside function.
Following terraform code is used
resource “azurerm_api_management” “apim” {
name =
location =
resource_group_name =
publisher_email = var.publisheremail
publisher_name = var.publishername
sku_name = Developer_1
protocols {
enable_http2 = true
}
}
resource “azurerm_api_management_backend” “apimbe” {
name =
resource_group_name =
api_management_name = azurerm_api_management.apim.name
resource_id = “https://management.azure.com/subscriptions/resourceGroups//providers/Microsoft.Web/sites/”
protocol = “http”
url = “https://.azurewebsites.net/api/”)
depends_on = [ azurerm_api_management.apim ]
}
resource “azurerm_api_management_api” “apimapi” {
name =
resource_group_name =
api_management_name = azurerm_api_management.apim.name
revision = “1”
display_name = <AzureFunctionName>
description = <AzureFunctionName>
api_type = "http"
path = ""
protocols = ["https"]
service_url = format("https://<AzureFunctionName>.azurewebsites.net/api")
subscription_required = true
# This doesn't work as there is no openapi or swagger created in azure function
# import {
# content_format = "swagger-link-json"
# content_value = "https://<AzureFunctionName>.azurewebsites.net?format=json"
# }
depends_on = [ azurerm_api_management.apim ]
}
resource “azurerm_api_management_api_policy” “apimapipolicy” {
api_name = azurerm_api_management_api.apimapi.name
api_management_name = azurerm_api_management.apim.name
resource_group_name =
# xml_content = <<XML
# <policies>
# <inbound>
# <base />
# <set-backend-service base-url="https://<AzureFunctionName>.azurewebsites.net/api/" />
# </inbound>
# </policies>
# XML
xml_content = <<XML
<policies>
<inbound>
<base />
<set-backend-service backend-id="<AzureFunctionName>" />
</inbound>
</policies>
XML
}