How to: List all Feeds, Packages, and Versions at Azure Artifacts in Azure DevOps

Vinicius Moura
2 min readApr 14, 2021

This report will show in Power BI all Feeds (internals and externals), Packages, and Versions

An original script is available on my GitHub repository. See below this script:

Let’s go understand each command used.

  1. PowerShell script will receive the following parameters:
  • $PAT = Personal Access token to connect on Azure DevOps;
  • $Organization = Organization URL to list all Feeds, PAckages, and Versions;
  • $Connstr = connection string to Azure SQL Database that stores the report information. To create this report, it’s necessary to create previously a Azure SQL Server and Database and run a script below:

2. Feed Management Get Feeds = use this command to list all Feeds on the respective organization

$UriRootFeeds = "https://feeds.dev.azure.com/$($Organization)/" $UriFeeds = $UriRootFeeds + "_apis/packaging/feeds?api-version=6.0-preview.1"$FeedResult = Invoke-RestMethod -Uri $UriFeeds -Method get -Headers $AzureDevOpsAuthenicationHeaderForeach ($feed in $FeedResult.value)
{
Write-Host @feed.name
}

3. Artifact Details Get Packages = use this command to list all Packages on the respective Feed

$UriFeedPackages = $UriRootFeeds + "$($feed.project.name)/_apis/packaging/Feeds/$($feed.id)/packages?api-version=6.0-preview.1"   

$FeedPackageResult = Invoke-RestMethod -Uri $UriFeedPackages -Method get -Headers $AzureDevOpsAuthenicationHeader

Foreach ($feedpackage in $FeedPackageResult.value)
{
Write-Host $feedpackage.name
}

4. Artifact Details Get Package Version = use this command to list all Versions on the respective Package

$UriFeedPackageVersion = $UriRootFeeds + "$($feed.project.name)/_apis/packaging/Feeds/$($feed.id)/Packages/$($feedpackage.id)/versions?api-version=6.0-preview.1"$FeedPackageVersionResult = Invoke-RestMethod -Uri $UriFeedPackageVersion -Method get -Headers $AzureDevOpsAuthenicationHeader

Foreach ($feedpackageversion in $FeedPackageVersionResult.value) {
Write-Host $feedpackageversion.version
}

5. Artifact Details Query Package Version Metrics = use this command to get metrics on the respective Package Version (download and users)

$BodyPackageVersionIds = @{ packageVersionIds = @($feedpackageversion.id) } | ConvertTo-Json     

$UriFeedPackageVersionUsage = $UriRootFeeds + "$($feed.project.name)/_apis/packaging/Feeds/$($feed.id)/Packages/$($feedpackage.id)/versionmetricsbatch?api-version=6.0-preview.1"

$FeedPackageVersionUsageResult = Invoke-RestMethod -Uri $UriFeedPackageVersionUsage -ContentType "application/json" -Method Post -Body $BodyPackageVersionIds -Headers $AzureDevOpsAuthenicationHeader
foreach ($feedpackageversionusage in $FeedPackageVersionUsageResult.value)
{
Write-Host $feedpackageversionusage.downloadCount }

6. After executing the script on PowerShell, this information is stored in a table in Azure SQL.

7. After insert information into a table, I connected this database on Power BI:

  • Feed (1) = select the respective Feed;
  • Package (2)= select the respective Package;
  • Package Name (3) = information about respective Package selected;
  • Package Source (4) = information about respective Package Source selected;
  • Package Type (5) = information about respective Package Type selected;
  • Latest version (6) = the actual version of the respective Package in use, is highlighted.

--

--