What does my APIM Product look like to external viewers
  • 14 Dec 2020
  • 1 Minute To Read
  • Contributors
  • Print
  • Comments
  • Share
  • Dark
    Light

What does my APIM Product look like to external viewers

  • Print
  • Comments
  • Share
  • Dark
    Light

As a followup to the other article I may also want to look at what the API looks like to the subscriber of a product. Again we have the azure portal or the APIM developer portal which are ok but its not that easy for you to see the paths in a way which gives you a good simple view across your API's within the product.

Bring in another little powershell script below

$resourceGroupName = '[Resource Group Here]'
$apimServiceName = '[APIM Name Here]'

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

$apimInstance = Get-AzApiManagement -ResourceGroupName $apimContext.ResourceGroupName -Name $apimContext.ServiceName

$productList = Get-AzApiManagementProduct -Context $apimContext
foreach($product in $productList){

    Write-Host 'Product:' $product.Title
    #Write-Host "`t`Id:" $product.Id
        
    $apiList = Get-AzApiManagementApi -Context $apimContext -ProductId $product.ProductId
    
    foreach($api in $apiList){        
        Write-Host "`tAPI: " $api.Path
        Write-Host "`t`tName:" $api.Name
        
        $fullPath = $apimInstance.RuntimeUrl + '/' + $api.Path
        Write-Host "`t`tFull Path:" $fullPath

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

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

    Write-Host ''
}

The below picture shows you a similar view to the previous post, but rather than for all API's it will list each product and then the API's in turn which are part of that product.

image.png

I find these useful to get a view of what my API looks like and hopefully it will help someone else out too

Was This Article Helpful?