Today on my way to QA i was met by this:

2019-11-05T06:34:51.5322889Z ##[error]Error: Failed to get resource ID for resource type 'Microsoft.Web/Sites' and resource name '---redacted---'. Error: Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired.

Hmm, i think my credentials have expired...

This is actually quite a simple fix using the Azure cli and the command for handling credentials. az ad sp credential [1]

With this command you can list, delete and reset your service principals. This time I was only looking for the ability to reset my service principal.

To reset your service principal run this az ad sp credential reset --name [id|name]

This will reset you service principal, regenerate a new password and move the expire day one year forward.

To set you own password just provide the -p or --password switch az ad sp credential reset --name [id|name] -p newSecretPassword

To extend the expiration day even further than one year (which is the default value) provide the --years switch followed by the years you want it valid or you can provide your own expiration date by providing the --end-date switch. az ad sp credential reset --name [id|name] -p newSecretPassword --years 2 or az ad sp credential reset --name [id|name] -p newSecretPassword --end-date '2299-12-31'

  1. az ad sp credential | Microsoft Docs