Just discovered that there is another place within SonarCloud that requires a valid Azure token. See this post as well: Sonarcloud analysis has started failing for azure devops with token invalid - #2 by Marcin_Majewski
Also there is a way to see the debug output within the SonarCloudPrepare
task:
extraProperties: |
sonar.verbose=true
In my case it showed a request to Azure failing with a 401 status which gave a clue. I updated the token within Sonarcloud
> Profile picture (right top)
> (Your organisation)
> Administration
> Organization settings
. Scroll down to the Azure DevOps connectivity management
section. There you can check whether the token is valid. A bit strange that the main branch kept working but the PR’s were failing.