Anderson, the former D-back, had eight K's of his own in six innings but got tagged with the loss to fall to 5-2.
Ray has now allowed just one run total in his past five starts, starts, spanning 37 1/3 innings after his scoreless three-hit performance. He was pulled after walking two Brewers with two outs in the seventh. Anderson, who allowed one run on four hits, had a 22-inning scoreless streak snapped in the first inning on an RBI groundout off the bat of Jake Lamb.
The D-backs got homers from Brandon Drury, Chris Herrmann and David Peralta off two Milwaukee relievers to break open the game in a five-run seventh.