Sanchez erased a 1-0 deficit in the second inning with a run-scoring groundout, then delivered a two-run double in the fourth for a 3-1 Giants lead.
Petit (2-0) struck out 10, yielding two runs on seven hits with a walk.
The rookie right-hander, making his second major league, also provided an RBI single as the Giants took 2-of-3 from the Diamondbacks.
Arizona's Patrick Corbin (13-5) was tagged for five runs on nine hits over five full innings.
Megyn Kelly: Santa Claus and Jesus are both white men
Wisconsin business offering 'therapeutic cuddling' forced to close