One of the things I struggle with a bit with Azure APIM is the holistic view of what my API looks like if I am an external viewer looking at it.

When you work in the Azure Portal you get a pretty interface that is nice and easy to work with but the problem is that the interface masks some of the key information about what your paths look like on the API so its difficult to know if its an API which is easy to understand to the external user.

With this in mind I have put together the below Powershell script which will give you an easy to see view on what your API looks like to external viewers.

$resourceGroupName = '[RESOURCE GROUP GOES HERE]'
$apimServiceName = '[API NAME GOES HERE]'

$apimContext = New-AzApiManagementContext -ResourceGroupName $global:resourceGroupName -ServiceName $global:apimServiceName
Write-Host 'APIM =' $apimContext.ServiceName

$apiList = Get-AzApiManagementApi -Context $apimContext

foreach($api in $apiList){
    #Write-Host $api.Name
    Write-Host "API: " $api.Path        
    Write-Host "`tName:" $api.Name

    $fullPath = $apimInstance.RuntimeUrl + '/' + $api.Path
    Write-Host "`tFull Path:" $fullPath

    Write-Host "`tOperations:"

    $operationList = Get-AzApiManagementOperation -Context $apimContext -ApiId $api.ApiId
    foreach($operation in $operationList){
        Write-Host "`t`t"$operation.Method ": " $operation.UrlTemplate
        Write-Host "`t`t`tName:" $operation.Name

        $fullPath = $apimInstance.RuntimeUrl + '/' + $api.Path + $operation.UrlTemplate
        Write-Host "`t`t`tFull Path:" $operation.Method':' $fullPath
        Write-Host ''
    }

    Write-Host ''
}
}

If I run this script it will give me a view of the API’s and if you look at the below screen shot you can see what it would look like for the echo API.

This gives me an easy view across the API’s so I can see all of the paths together and see if anything looks like it is not named correctly.

This is a cross post from my integration playbook – https://www.integration-playbook.io/v1/docs/what-does-my-api-look-like-to-external-viewers

 

Buy Me A Coffee