Azure APIM- API路径问题在版本集中

发布于 2025-02-12 21:26:47 字数 2046 浏览 0 评论 0原文

我正在创建一个带有2个API的APIM版本:

  1. sample-data/v1
  2. sample-data/v2

都具有相同的路径sample> sample-data,但API的不同版本(v1& v2)。

以下是我的Terraform配置:

resource "azurerm_api_management_api" "sample_data_api_v1" {
  name                = "sample-data-api-v1"
  resource_group_name = data.azurerm_resource_group.boxrg.name
  api_management_name = module.api001.name
  revision            = "1"
  display_name        = "sample Data API v1"
  path                = "sample-data"
  protocols           = ["https"]
  version             = "v1"
  version_set_id      = azurerm_api_management_api_version_set.sample-data-api-version-set.id
  import {
    content_format = "openapi"
    content_value  = templatefile("${path.module}/template-files/api-spec/sample-data-v1-openapi.yml", {})
  }

}

resource "azurerm_api_management_api" "sample_data_api_v2" {
  name                = "sample-data-api-v2"
  resource_group_name = data.azurerm_resource_group.boxrg.name
  api_management_name = module.api001.name
  revision            = "1"
  display_name        = "sample Data API v2"
  path                = "sample-data"
  protocols           = ["https"]
  version             = "v2"
  version_set_id      = azurerm_api_management_api_version_set.sample-data-api-version-set.id
  import {
    content_format = "openapi"
    content_value  = templatefile("${path.module}/template-files/api-spec/sample-data-v2-openapi.yml", {})
  }
}

但是,这是指出路径sample-data 已经存在。如下:

错误:等待创建 /更新API :(名称为“ sample-data-api-v1” /服务名称“ .....” .....“ .. WaitforCompletion: 已超出了重试的数量:status Code = 400-原始错误:代码=“ vilenationError” 消息=“一个或多个字段包含不正确的值:” 详细信息= [{“ code”:“ validationErr”,“ message”:“带有指定URL路径'sample-data'已经存在的API

。通过门户,没问题。仅通过Terraform发生。 我无法理解问题的位置,因为尽管有相同的路径,但它们不应该冲突,因为Terraform/Azure将版本附加到URI路径中,使它们与众不同:

例如。

  1. /sample-data/ v1 //
  2. sample-data/ v2 /

我在做错了什么还是在某处这是一个错误? 谢谢。

I am creating a APIM version set with 2 APIs:

  1. sample-data/v1
  2. sample-data/v2

Both with same path sample-data but different version of the API (v1 & v2).

Below is my Terraform configuration:

resource "azurerm_api_management_api" "sample_data_api_v1" {
  name                = "sample-data-api-v1"
  resource_group_name = data.azurerm_resource_group.boxrg.name
  api_management_name = module.api001.name
  revision            = "1"
  display_name        = "sample Data API v1"
  path                = "sample-data"
  protocols           = ["https"]
  version             = "v1"
  version_set_id      = azurerm_api_management_api_version_set.sample-data-api-version-set.id
  import {
    content_format = "openapi"
    content_value  = templatefile("${path.module}/template-files/api-spec/sample-data-v1-openapi.yml", {})
  }

}

resource "azurerm_api_management_api" "sample_data_api_v2" {
  name                = "sample-data-api-v2"
  resource_group_name = data.azurerm_resource_group.boxrg.name
  api_management_name = module.api001.name
  revision            = "1"
  display_name        = "sample Data API v2"
  path                = "sample-data"
  protocols           = ["https"]
  version             = "v2"
  version_set_id      = azurerm_api_management_api_version_set.sample-data-api-version-set.id
  import {
    content_format = "openapi"
    content_value  = templatefile("${path.module}/template-files/api-spec/sample-data-v2-openapi.yml", {})
  }
}

However this is complaining that the path sample-data already exist. as below:

Error: waiting on creating/updating Api: (Name "sample-data-api-v1" / Service Name "....." / Resource Group "....."): Future#WaitForCompletion:
the number of retries has been exceeded: StatusCode=400 -- Original Error: Code="ValidationError"
Message="One or more fields contain incorrect values:"
Details=[{"code":"ValidationError","message":"API with specified URL path 'sample-data' already exists.","target":"path"}]

I can do this manually via portal, no problem. Only happens via Terraform.
I am failing to understand where the issue is because despite having same path, they shouldnt conflict as the Terraform/Azure appends the version to the URI path making them different:

eg.

  1. /sample-data/v1/
  2. /sample-data/v2/

Am I doing something wrong or is this a bug somewhere?
Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文