title: How to use AzureCLI in azure-pipelines.yml to delete old files on Azure Blob Storage
body: <p>I'm using Azure DevOps and their Build and Release pipelines. As part of my build I'd like to delete old files from my Azure Blob storage. I'm using an <code>ubuntu-latest</code> vmImage.</p>
  
  <p>This task:</p>
  
  <pre><code>- task: AzureCLI@2
    displayName: Delete old files
    inputs:
      scriptType: pscore
      scriptLocation: inlineScript
      inlineScript: |
          date=`date -d "1 days ago" '+%Y-%m-%dT%H:%MZ'`
          az storage blob delete-batch -s $web --account-name xenobellstorage --if-unmodified-since $date
  </code></pre>
  
  <p>Produces this error, which doesn't match any params in their documentation.</p>
  
  <pre><code>Script failed with error: Error: Input required: connectedServiceNameARM
  </code></pre>
  
  <p>If I add <code>azureSubscription: 'Main subscription'</code> to the task, I get this error, with an <strong>Authorize resources</strong> button that doesn't work.</p>
  
  <pre><code>There was a resource authorization issue: "The pipeline is not valid. Job Job: Step AzureCLI input connectedServiceNameARM references service connection Main subscription which could not be found. The service connection does not exist or has not been authorized for use. For authorization details, refer to https://aka.ms/yamlauthz."
  </code></pre>
  
  <p>The <a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/process/resources?view=azure-devops#troubleshooting-authorization-for-a-yaml-pipeline" rel="nofollow noreferrer">linked page</a> suggests I go to <strong>Project Settings</strong> to authorize <strong>all pipelines</strong>, but that toggle doesn't work.</p>
  
  <p><a href="https://i.stack.imgur.com/PQ1SN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PQ1SN.png" alt="Greyed out grant access button"></a></p>
  
  <p>How can I run this AzureCLI task on my Ubuntu VM?</p>
  
  <hr>
  
  <p>The full YAML file I used that fixed my problem:</p>
  
  <pre><code># Node.js
  # https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
  
  trigger:
  - master
  
  pool:
    vmImage: 'ubuntu-latest'
  
  steps:
  - task: NodeTool@0
    inputs:
      versionSpec: '10.x'
    displayName: 'Install Node.js'
  
  - script: |
      npm install
    displayName: 'npm install'
  
  - script: |
      grunt --gruntfile gruntfile.js prod
    displayName: 'grunt production build'
  
  - task: CopyFiles@2
    displayName: 'Copy files'
    inputs:
      SourceFolder: '$(System.DefaultWorkingDirectory)'
      Contents: |
        game/**
      TargetFolder: '$(Build.ArtifactStagingDirectory)'
  
  - task: PublishBuildArtifacts@1
    displayName: 'Publish files'
    inputs:
      PathtoPublish: '$(Build.ArtifactStagingDirectory)'
      ArtifactName: 'drop'
  
  - task: AzureCLI@2
    displayName: Delete old files
    inputs:
      azureSubscription: 'Main subscription (abc-123-idd)'
      scriptType: pscore
      scriptLocation: inlineScript
      inlineScript: |
          az storage blob delete-batch -s '$web' --account-name mystorage --if-unmodified-since $(date -d "1 days ago" '+%Y-%m-%dT%H:%MZ')
  </code></pre>