gpt4 book ai didi

azure - 如何将 azure 函数应用程序导入到 terraform 中的 apim?

转载 作者:行者123 更新时间:2023-12-03 03:27:46 25 4
gpt4 key购买 nike

我有一个问题,是否有一种方法可以使用 terraform 将 azure funtion 应用程序导入 api 管理 api。 https://learn.microsoft.com/en-us/azure/api-management/import-function-app-as-api

下面是 terraform 资源的链接,但我在导入部分没有看到功能应用程序

导入 block 支持以下内容:content_format -(必需)应从中导入 API 定义的内容格式。可能的值为:openapi、openapi+json、openapi+json-link、openapi-link、swagger-json、swagger-link-json、wadl-link-json、wadl-xml、wsdl 和 wsdl-link。

https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/api_management_api

这可能吗?

导入函数应用程序作为API

最佳答案

尝试以下 terraform 代码,通过 Azure api 管理将函数应用程序导入为 api。我在 import block 下添加了函数 App Url,并且能够成功部署。

main.tf:

provider "azurerm"{
features{}
}

resource "azurerm_resource_group" "example" {
name = "<resource name>"
location = "West Europe"
}

resource "azurerm_storage_account" "example" {
name = "xxxxstorageaccount"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
account_tier = "Standard"
account_replication_type = "LRS"
}

resource "azurerm_app_service_plan" "example" {
name = "azure-functions-test-service-plan"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name

sku {
tier = "Standard"
size = "S1"
}
}

resource "azurerm_function_app" "example" {
name = "xxxfunctionapp"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
app_service_plan_id = azurerm_app_service_plan.example.id
storage_account_name = azurerm_storage_account.example.name
storage_account_access_key = azurerm_storage_account.example.primary_access_key
}

resource "azurerm_api_management" "example" {
name = "xxxxapim"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
publisher_name = "xxx"
publisher_email = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c7bfbfbf87b3a2b5b5a6a1a8b5aae9aea8" rel="noreferrer noopener nofollow">[email protected]</a>"

sku_name = "Developer_1"
}

resource "azurerm_api_management_api" "example" {
name = "xxxapi"
resource_group_name = azurerm_resource_group.example.name
api_management_name = azurerm_api_management.example.name
revision = "1"
display_name = "Example API"
path = "example"
protocols = ["https"]

import {
content_format = "swagger-link-json"
content_value = azurerm_function_app.example.name
}
}

地形计划:

enter image description here

地形应用:

enter image description here

部署在门户中:

enter image description here

引用:Terraform registry

关于azure - 如何将 azure 函数应用程序导入到 terraform 中的 apim?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75336436/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com