Barmes' two-run homer gave the winners a quick 2-0 lead in the top of the first inning. He joined Matt Holliday and Garrett Atkins with three hits.
Already leading 5-3, Colorado scored eight runs in the final three innings. Holliday hit a three-run homer in the ninth after Atkins hit a two-run shot in the eighth.
Yorvit Torrealba had two hits and two RBI while five players scored twice for the Rockies, who avoided a second straight three-game sweep against the Diamondbacks.
Winning pitcher Aaron Cook (1-1) surrendered three earned runs and eight hits in six innings with three walks and four strikeouts.
The losing pitcher was D-Backs' starter Edgar Gonzalez (0-1).
'Happy' fan videos make Pharrell cry [VIDEO]
Pistorius testifies he didn't consciously pull trigger when he shot girlfriend