Member-only story
How to get Azure Artifact Feed ID from user readable name
This is a simple post but with some affective content. Sometimes when using Azure DevOps YAML Pipelines you might need to interact with the Azure DevOps Artifacts and their Feeds. However, to do this you need to obtain the Feed ID, which is not obvious where it is and how to get it, especially during the pipeline dynamically.
Unfortunately there is no CLI or dynamic method using the Feed Name to get the Artifact Feed ID, so instead we need to use the REST API. Azure DevOps exposes a GET endpoint for getting a list of feeds in the whole organization as documented here https://learn.microsoft.com/en-us/rest/api/azure/devops/artifacts/feed-management/get-feeds?view=azure-devops-rest-6.0
You could use native PowerShell to invoke a web request to the endpoint documented in the above, but you can also instead use the az devops CLI. Using this cut out a few lines of code and can make the authentication much easier. Although this CLI does not have a direct feed argument like az devops feeds
you can use the invoke
command by passing in key verbs to execute predefined REST API endpoints.
First you will need to login, which you can decide how best suites your platform by following the documentation, but in simple terms you need to run
az devops login