Azure DevOps: using DefaultAzureCredential in an Azure Pipeline with AzureCLI@2

How to use DefaultAzureCredential in an Azure DevOps pipeline in the same way as you can locally.