SonarCloud Scan fails during Pull Request

Template for a good new topic, formatted with Markdown:

  • ALM used (Azure DevOps)
  • CI system used (Azure DevOps)
  • Scanner command used when applicable (private details masked)
    steps:
  • task: SonarSource.sonarcloud.############.SonarCloudAnalyze@1
    displayName: ‘Run Code Analysis’
  • Languages of the repository (C#)
  • Only if the SonarCloud project is public, the URL
    • And if you need help with pull request decoration, then the URL to the PR too
  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
1. ##[error]ERROR: Error during SonarScanner execution

ERROR: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator

ERROR:

ERROR: Error during SonarScanner execution

ERROR: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator

ERROR:

##[error]ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.

ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.

##[error]The process 'D:\a\_tasks\SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1\1.32.0\sonar-scanner\bin\sonar-scanner.bat' failed with exit code 1

Finishing: Run Code Analysis
  • Steps to reproduce
SonarCloud set up in Azure piplines classic editor with continuous integration enabled for all branches. When a pull request is made, the scan fails with a message that the project does not exist, but future scans on any branch scan perfectly well. 
  • Potential workaround
Were pull requests somehow disabled? Is there some way to enable pull requests in ADO? Other similar problems claim there is a permissions issue with the connection. 

There is a similar problem here, but I don't understand the solution proposed:
https://community.sonarsource.com/t/sonarcloud-status-check-and-decoration-not-working-on-azure-devops-pull-requests/29392