azureazure-api-managementopenapiazureportalibm-api-management

How to disable the try it function in the Azure API management developer portal?


On the Azure API management developer portal, there is a "Try it" feature to test api request in your browser.

The try it button:

The try it button

The test page

Is it possible to disable/remove this feature? I don't want developers to be able to post test data inside our production environment.


Solution

  • I found a way to hide the try it button. This doesn't completely disable the feature, but makes it hidden for the user.

    1. Go to the Developer portal logged in as an admin.

    2. Click on the Edit icon on the top right

    Edit icon

    1. Select Template => Operation.

    2. This should open a markup window. Look for the try it button. It should look like this

    <a class="btn btn-primary" href="{{consoleUrl}}" id="btnOpenConsole" role="button">
        Try it
    </a>

    1. Either remove the tag entirely or wrap it in a if/unless. Azure apim uses the DotLiquid language for its templates. I ended up doing this.

    {% assign apiNamePrefix = api.name | slice: 0, 4 %}
    {% if apiNamePrefix == 'TEST' %}
    <a class="btn btn-primary" href="{{consoleUrl}}" id="btnOpenConsole" role="button">
        Try it
    </a>
    {% endif %}

    1. Save your changes. Then Publish.