azure-devopsbuildyamlazure-pipelinesazure-cli

Cannot run Azure CLI task on yaml build


I'm starting to lose my sanity over a yaml build. This is the very first yaml build I've ever tried to configure, so it's likely I'm doing some basic mistake.

This is my yaml build definition:

name: ops-tools-delete-failed-containers-$(Date:yyyyMMdd)$(Rev:.rrrr)

trigger:
  branches:
    include:
      - master
      - features/120414-delete-failed-container-instances

schedules:
- cron: '20,50 * * * *'
  displayName: At minutes 20 and 50
  branches:
    include:
    - features/120414-delete-failed-container-instances
  always: 'true'

pool: 
  name: Standard-Windows

variables:
  - name: ResourceGroup
    value: myResourceGroup

stages:
  - stage: Delete
    displayName: Delete containers
    jobs:
      - job: Job1
        steps:
        - task: AzureCLI@2
          inputs:
            azureSubscription: 'CPA (Infrastructure) (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx)'
            scriptType: 'pscore'
            scriptLocation: 'scriptPath'
            scriptPath: 'General/Automation/ACI/Delete-FailedContainerInstances.ps1'
            arguments: '-ResourceGroup $(ResourceGroup)'

So in short, I want to run a script using an Azure CLI task. When I queue a new build it stays like this forever:

enter image description here

I've tried running the same task with an inline script without success. The same thing happens if I try to run a Powershell task instead of an Azure CLI task.

What am I missing here?


Solution

  • TL;DR issue was caused by (lack of) permissions.

    More details

    After enabling the following feature I could see more details about the problem: Multi-stage pipelines feature

    The following warning was shown after enabling the feature: Build warning

    Clicking on View shows the Azure subscription used in the Azure CLI task. After clicking on Permit, everything works as expected.

    enter image description here