'ARM/Bicep template for importing API Management operations

I'm putting the final pieces together on deploying a bunch of APIs through API Management.

I have a number of App and Logic App backends that are combined in API Management. Reverse engineering an ARM template from the portal suggests I have to write out each and every operation by hand to create the operations vi Bicep.

Is there a way, that like the portal, I can instruct ARM to use the OpenAPI specification generated automatically by the backend Apps and Logic Apps to automatically populate the operations?

Given the variety of operational paths, I feel like I'm going to be here all week typing them out as the variance is too much to have a loop.



Solution 1:[1]

Here is an example on how I used OpenAPI for populating APIM Gateway. I passed the OpenAPI spec converted to single line into the Value field and set the format field to openapi+json. Here is an example

resource ImportedOpenapi 'Microsoft.ApiManagement/service/apis@2021-12-01-preview' = {
  parent: apimservicesymbolicname 
  name: 'ImportOpenApi'
  properties: {
    name: 'MyTestAPI'
    apiType: 'http'
    contact: {
      email: '[email protected]'
      name: 'test'
    }
    format: 'openapi+json'
    path: 'myapi'
    protocols: [
      'https'
    ]
    isCurrent: true
    subscriptionRequired: true
    type: 'http'
    value: '{"openapi":"3.0.1","info":{"title":"MyApi","contact":{},"version":"1.0"},"servers":[{"url":"https://xyz.api"}],"paths":...'
    }
  }

Solution 2:[2]

Try putting in substr_replace($term->name,"",-1), check documentation for more info, this should delete comma from last string.

Solution 3:[3]

just add a counter to check the last item of the array

$post = get_post();
$terms = wp_get_post_terms($post->ID, 'genre');
if ($terms)
{
    $output = '';
    $i = 0;
    foreach ($terms as $term) {
      $output .= '<a href="' . get_term_link($term->slug, 'genre') . '">' . $term->name . '</a> ';

      $output .= ($i == count($terms) - 1) ? '' : ',';
      $i++;
    }
};
echo $output;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 shaswata pal
Solution 2
Solution 3 Yazan Fouad Aldbaisy