SAN FRANCISCO (AP) -- Hitting his first home run in a month gave Aaron Hill a sense of relief. Doing so in a victory made it even better.
''It felt good to put a run on the board,'' Hill said. ''There are always going to be times when you will be struggling. It's good just to contribute.''
David Peralta and Gerardo Parra each added two hits for the Diamondbacks, who won their fourth in six games.
Marco Scutaro went hitless in two at-bats with a walk in his season debut for the Giants, who were shut out for the fifth time in 13 games.
Miley (5-6) allowed four hits and won his second straight start for the first time since early April. He has given up three runs over his past 22 2/3 innings.
''I found it later in the game. They were hitting the ball hard but right at people,'' Miley said.
Brad Ziegler worked the eighth and Addison Reed pitched the ninth for his 21st save in 26 chances.
Ryan Vogelsong (5-7) gave up two runs and six hits in 6 1/3 innings.
''With two runs it shows you how good a job Wade did and also on the other side with Vogelsong,'' Hill said.
Vogelsong has lost his last four starts despite a 2.19 ERA over that span. The Giants have been shut out in each of his last three starts and given him no support in his last 24 2/3 innings.
''I'm sure he's frustrated,'' Giants manager Bruce Bochy said. ''He had a quality start, good stuff. I wish we could have gotten him some runs. He really threw the ball well.''
Scutaro, a postseason star for the Giants in their run to the 2012 championship, received a standing ovation when he came to the plate for his first at-bat of the season. He drew a walk.
Scutaro has missed the first half of the year because of a back problem.
Miley permitted one hitter - Brandon Belt, who singled and walked twice - to reach third base and that came with two outs in the seventh.
''I couldn't throw him a strike,'' Miley said. ''I wish I didn't walk him.''
Miley gave up one leadoff hit, and then promptly picked off Gregor Blanco in the fifth.
''That pickoff hurt,'' Bochy said. ''We were trying to bunt him over to second, maybe put a little more pressure on the pitcher with some good hitters coming up. He has a good move and got him.''
Hill homered with one out in the fourth. He hit a leadoff double in the seventh and Parra's RBI single ended Vogelsong's day.
NOTES: The Diamondbacks pushed RHP Chase Anderson's scheduled start Sunday to five days after the All-Star break as a proactive move to reduce the possibility of fatigue as his workload increased. ''It will be good for him, give him time to recover physically and mentally,'' Arizona manager Kirk Gibson said. LHP Vidal Nuno will make Sunday's start instead. Recently acquired from the New York Yankees, Nuno threw seven shutout innings in his first appearance with the Diamondbacks on Tuesday. ... Parra drove in just his second run since June 7. He entered the game hitting .180 (20 for 111) since then. ... Arizona 1B Paul Goldschmidt doubled in the first inning and has reached base safely in a career-high 32 straight game, the longest string by a Diamondbacks player since Orlando Hudson went 33 straight in 2007. ... LHP Madison Bumgarner (9-7, 3.36) pitches for the Giants on Sunday. He's on a three-game losing streak after giving up a season-high six runs in his last start. . Giants SS Brandon Crawford was given the day off. . Arizona's Martin Prado went hitless in four at bats and had his 10-game hitting streak end.