AzureDevops sonar.branch.name vs pull request build

My case:
Shared build for PR and branch (with some conditions in some steps)

Is there a way to set up scanning on Azure Devops for pullrequests and branch builds with a single configuration?

Currently I need to set sonar scanner twice - one for branch build with sonar.branch.name and second one for PR build, without the parameter.
image

The SonarCloud extension for Azure DevOps handles all this for you, so that you don’t need to set up 2 build definitions.