1

in my main.bicep I have the following call to a module to create api-resources :

module apiModule './api.bicep' = {
  name: 'apiDefinition'
  params: {
    apiName: 'myapiName'     
    products: ['product1','product2']
  }
}

in the api.bicep I create an apidefinition and products:

resource apiDefinition 'Microsoft.ApiManagement/service/apis@2020-12-01' = {
  name: apiName
  parent: apimService
  properties: {
    path: apiName
    description: '${apiName} API'
    displayName: '${apiName} API'
    format: 'openapi+json'
    value: openapi
    subscriptionRequired: true
    type: 'http'
    protocols: [ 'https' ]
  }
}

to create the products I use a for-loop to iterate the products input parameter :

resource Product 'Microsoft.ApiManagement/service/products@2020-12-01' = [for product in products: {
  name: prodcuct
  parent: apimService
  properties: {
    approvalRequired: true
    description: 'product for ${apiName} apis'
    displayName: '${product}-Product'
    state: 'published'
    subscriptionRequired: true
  }
}]

Now I need to link those 2 products to my api :

resource apiproductlink 'Microsoft.ApiManagement/service/products/apis@2020-12-01' = {
  name: apiName
  parent: Product 
}

-> this will not work since parent: Product is not a single resource, it has 2 products. And it seems not possible to iterate over the previous create products to iterate.

So my question : How can I link one API to multiple products ?

David
  • 15
  • 3

0 Answers0