二头肌API管理多个产品

发布于 2025-02-13 07:52:30 字数 1061 浏览 1 评论 0原文

我正在使用二头肌文件创建API管理,但是当我尝试创建一个产品时,仅当我在模板中仅创建一个产品时才能起作用。是否有某种方式创建与API管理相关的多个产品的方法,以下是示例批准

resource apim 'Microsoft.ApiManagement/service@2021-08-01' existing = {
  name: 'apim'
}

resource lambdaStoreApi 'Microsoft.ApiManagement/service/apis@2020-12-01' = {
  name: 'api'
  parent: apim
  properties:{
    format: 'swagger-json'
    value: loadTextContent('./swagger.json')
    path: 'path'
  }
}

resource product1 'Microsoft.ApiManagement/service/products@2020-12-01' = {
  name: '${apim.name}/product1'
  properties: {
    displayName: 'displayName'
    description: 'description'
    subscriptionRequired: true
    approvalRequired: false
    state: 'published'
  }
}

resource product2 'Microsoft.ApiManagement/service/products@2020-12-01' = {
  name: '${apim.name}/product2'
  properties: {
    displayName: 'displayName'
    description: 'description'
    subscriptionRequired: true
    approvalRequired: false
    state: 'published'
  }
}

我会出现错误“已经存在相同名称的产品” ,但前提是我尝试使用超过1个产品。

有什么方法可以使用多个产品创建?

I'm creating a api managment using bicep files, but when i try to create a products it works only when i created just one in the template. Is there somehow a way to create multiple products related with api management, below is the sample approch

resource apim 'Microsoft.ApiManagement/service@2021-08-01' existing = {
  name: 'apim'
}

resource lambdaStoreApi 'Microsoft.ApiManagement/service/apis@2020-12-01' = {
  name: 'api'
  parent: apim
  properties:{
    format: 'swagger-json'
    value: loadTextContent('./swagger.json')
    path: 'path'
  }
}

resource product1 'Microsoft.ApiManagement/service/products@2020-12-01' = {
  name: '${apim.name}/product1'
  properties: {
    displayName: 'displayName'
    description: 'description'
    subscriptionRequired: true
    approvalRequired: false
    state: 'published'
  }
}

resource product2 'Microsoft.ApiManagement/service/products@2020-12-01' = {
  name: '${apim.name}/product2'
  properties: {
    displayName: 'displayName'
    description: 'description'
    subscriptionRequired: true
    approvalRequired: false
    state: 'published'
  }
}

I am getting error "Product with the same name already exists", but only if I try with more than 1 product.

Is there some way to create with more than one product?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

娇妻 2025-02-20 07:52:30

查看

显示名称:产品名称。字符串(必需)。

displayName(产品名称)也必须是唯一的。您只需要给这个属性一个独特的价值:

resource product1 'Microsoft.ApiManagement/service/products@2020-12-01' = {
  name: '${apim.name}/product1'
  properties: {
    displayName: 'product1'
    ...
  }
}

resource product2 'Microsoft.ApiManagement/service/products@2020-12-01' = {
  name: '${apim.name}/product2'
  properties: {
    displayName: 'product2'
    ...
  }
}

Looking at the documentation:

displayName: Product name. string (required).

The displayName (product name) also have to be unique. You just need to give this property a unique value:

resource product1 'Microsoft.ApiManagement/service/products@2020-12-01' = {
  name: '${apim.name}/product1'
  properties: {
    displayName: 'product1'
    ...
  }
}

resource product2 'Microsoft.ApiManagement/service/products@2020-12-01' = {
  name: '${apim.name}/product2'
  properties: {
    displayName: 'product2'
    ...
  }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文