If you have the option, Github offers Actions which allow you to run workflows on different events - one of them being push.
If Github is not an option, I would recommend creating a build where deployment of the artifacts only happens if the build is done on master.
On your feature branches, on checkin, a build will happen which will pull the latest code, compile, and then run unit tests, security scanning, and code coverage (if applicable). Since this is a feature branch, the build ends there.
If it is on master, it then performs the steps to package/deploy the artifacts.
In Branches > Master > Branch Policies (in the ellipses menu), add a Build Validation.
I recommend marking it required.
If you aren't worried about merge conflicts causing a rebuild, you can make it expire immediately upon master changing (requiring a rebuild, which will fail on merge conflicts).
If you are a large team where you might frequently step on one another, you can make it never expire and leave it up to the developer to fix manually before they are able to merge.