title: Running Azure CLI script from release pipeline using Service Principal - invalid_client
body: <p>I have an Azure CLI script which runs perfectly well in the Cloud Shell but I run into trouble when I try to include it in a devops release pipeline. For debugging purposes I've reduced the script to simply signing-in as a <em>Service Principal</em> and then retrieving the version...</p>
  
  <pre><code>az login --service-principal -u http://[Service Principal name] -p [Service Principal password] --tenant [Service Principal tenant GUID]
  az --version
  </code></pre>
  
  <p>...but it still incurs the same error.</p>
  
  <p>Here are the properties of my <em>Azure CLI</em> task:</p>
  
  <p>Script Type: <code>Shell</code><br>
  Script Location: <code>Inline script</code><br>
  Inline Script: [<em>as above</em>]<br>
  Script Arguments:<br>
  Access service principal details in script: <code>false</code><br>
  Use global Azure CLI configuration: <code>false</code><br>
  Working Directory:<br>
  Fail on Standard Error: <code>false</code><br>
  Enabled: <code>true</code><br>
  Continue on error: <code>false</code>*<br>
  Environment Variables:  </p>
  
  <p>And the error is:</p>
  
  <blockquote>
    <p>2020-06-15T12:46:39.8710944Z ##[error]Error Code: [1]<br>
    2020-06-15T12:46:39.8724737Z ##[error]Error: Azure login failed<br>
    2020-06-15T12:46:39.8728448Z ##[error]Script failed with error: Get Token request returned http error: 401 and server response: {"error":"invalid_client","error_description":"AADSTS7000222: The provided client secret keys are expired. Visit the Azure Portal to create new keys for your app, or consider using certificate credentials for added security: <a href="https://docs.microsoft.com/azure/active-directory/develop/active-directory-certificate-credentials" rel="nofollow noreferrer">https://docs.microsoft.com/azure/active-directory/develop/active-directory-certificate-credentials</a><br>
    Trace ID: d0f42793-739e-4ce9-9118-5049086aa800<br>
    Correlation ID: 2ad50471-9c2a-4c02-a4d0-189efad2f0c8<br>
    Timestamp: 2020-06-15 12:46:39Z","error_codes":[7000222],"timestamp":"2020-06-15 12:46:39Z","trace_id":"d0f42793-739e-4ce9-9118-5049086aa800","correlation_id":"2ad50471-9c2a-4c02-a4d0-189efad2f0c8","error_uri":"<a href="https://login.microsoftonline.com/error?code=7000222" rel="nofollow noreferrer">https://login.microsoftonline.com/error?code=7000222</a>"}</p>
  </blockquote>
  
  <p>I was able to authenticate as this <em>Service Principal</em> using the Azure Cloud Shell so I'm puzzled as to why I apparently can't do the same from within the release pipeline.</p>
  
  <p>* I have tried with <em>Continue on error: true</em> and although the task completes the same error appears in the output.</p>