Unless our military is going to patrol the border on Mexican territory, I think it would be illegal.
It would be illegal as per the constitution, but to some so called conservatives, the constitution can be ignored (a la Obama) to serve their view point at any given time.
We routinely use our military on the border with Mexico, but not in an armed/patrolling mode. They build things like the fence and roads, and they monitor sensors.
FWIW, I’d like to see them used in a border guard role. The problem is to figure out how lethal they can be allowed to be.