Azure APIM- API路径问题在版本集中
我正在创建一个带有2个API的APIM版本:
- sample-data/v1
- 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", {})
}
}
但是,这是指出路径
错误:等待创建 /更新API :(名称为“ sample-data-api-v1” /服务名称“ .....” .....“ .. WaitforCompletion: 已超出了重试的数量:status Code = 400-原始错误:代码=“ vilenationError” 消息=“一个或多个字段包含不正确的值:” 详细信息= [{“ code”:“ validationErr”,“ message”:“带有指定URL路径'sample-data'已经存在的API
。通过门户,没问题。仅通过Terraform发生。 我无法理解问题的位置,因为尽管有相同的路径,但它们不应该冲突,因为Terraform/Azure将版本附加到URI路径中,使它们与众不同:
例如。
- /sample-data/ v1 //
- sample-data/ v2 /
我在做错了什么还是在某处这是一个错误? 谢谢。
I am creating a APIM version set with 2 APIs:
- sample-data/v1
- 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.
- /sample-data/v1/
- /sample-data/v2/
Am I doing something wrong or is this a bug somewhere?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论