How to use latest tagged image in AzureDevops Release Pipeline to deploy Azure Container Instance? [duplicate]

I have a Python Web application in Azure DevOps. I have set up CI/CD using Azure DevOps. In CI, I am pushing the image built on the master repo to the Azure Container Registry and tagging it as api:$(Build.BuildId).
I want to use the latest built image and deploy the container in Azure Container instances, how can I get the image with the latest build-id in AzureDevOps release pipeline?

Also, I want to deploy the same container to On-Prem running Docker, there as well how can I make sure to deploy the image with the latest build-id?

Source: StackOverflow