gpt4 book ai didi

azure - 如何通过 Azure API Manager 中的 Terraform 添加新的 API 版本?

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

我想在已有的 API 下添加新的 API 版本。我可以通过 Portal UI 轻松做到这一点,但是,有人可以指导我如何通过 Terraform 实现这一目标吗?任何示例片段都会有帮助。

我正在尝试将其 v1、v2 逆向工程到 Terraform 中。谢谢。

enter image description here

最佳答案

Terraform 支持 API Version Set并在 API 中引用它:

version - (Optional) The Version number of this API, if this API is versioned.
version_set_id - (Optional) The ID of the Version Set which this API is associated with.

NOTE:When version is set, version_set_id must also be specified

resource "azurerm_api_management_api_version_set" "example" {
name = "example-apimapi"
resource_group_name = var.resource_group_name
api_management_name = var.apim_name
display_name = "ExampleAPIVersionSet"
versioning_scheme = "Segment"
}

resource "azurerm_api_management_api" "example" {
name = "example-api"
resource_group_name = var.resource_group_name
api_management_name = var.apim_name
revision = "1"
display_name = "Example API"
path = "example_me"
protocols = ["https"]
service_url = "https://conferenceapi.azurewebsites.net/"
version = "v1"
version_set_id = azurerm_api_management_api_version_set.example.id


import {
content_format = "swagger-link-json"
content_value = "http://conferenceapi.azurewebsites.net/?format=json"
}
}

门户网站上有一个教程:Tutorial: Publish multiple versions of your API

When you create multiple versions, the Azure portal creates a version set, which represents a set of versions for a single logical API. Select the name of an API that has multiple versions. The Azure portal displays its Version set. You can customize the Name and Description of a virtual set.

关于azure - 如何通过 Azure API Manager 中的 Terraform 添加新的 API 版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72781391/

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