5

I need to fetch the latest image tag from Azure Container Registry (ACR) with a bash command in my pipeline and use that tag for container deployment. Here is what I could find with Azure cli:

  $ az acr repository show-tags --name myacr --repository myrepo --top 1

However this returns me the oldest tag.

How can I get the latest pushed tag from ACR repo?

Matrix
  • 2,399
  • 5
  • 28
  • 53

1 Answers1

6

See this doc: az acr repository show-tags and its parameters description:

Order the items in the results. Default to alphabetical order of names.

Based on your command, it is ordering by alphabetical order of names since you didn't specify the --orderby.

Add the parameter --orderby time_desc to make the result ordered by time.

Mengdi Liang
  • 17,577
  • 2
  • 28
  • 35
  • Unfortunately this does not take into account multiple versions. E.g. if `1.1.1` is published later than `1.2.0` then this will return `1.1.1`. There seems to be no way to return the "highest available version". – Tobias Oct 18 '21 at 13:08