parameters: 
  - name: ServiceConnectionName
    type: string
    default: azuresdkimages_container-registry
  - name: ImageId
    type: string
steps:
  - task: AzureCLI@2
    displayName: Docker Auth and Pull
    inputs:
      azureSubscription: ${{ parameters.ServiceConnectionName }}
      scriptType: pscore
      scriptLocation: inlineScript
      inlineScript: |
        # azuresdkimages.azurecr.io/pyrefautocr:latest -> azuresdkimages
        $containerRegistryName = ("${{ parameters.ImageId }}" -split "\/")[0].Replace(".azurecr.io", "")

        az acr login --name $containerRegistryName
        docker pull '${{ parameters.ImageId }}'
