Andriese, 28, is 3-4 with a 4.07 ERA and 1.22 WHIP in 2018. The Diamondbacks designated reliever Randall Delgado for assignment to make room for Andriese on their 40-man roster.
Andriese has appeared in 27 games, starting four this season. He's struck out 59 batters in 59.2 innings. Now in his fourth MLB season, Andriese was mostly used as a starter in 2016 and 2017.
"Ultimately, I'm not happy with the decision," Andriese said during spring training, per Roger Mooney of the Tampa Bay Times. "But at this point, where I'm at, you got to roll with it and just do the best to my ability. I'm not by any means mad about it. I'll just take the opportunity and learn from it and go on."
Shaffer, 21, was the 23rd-ranked prospect in the Diamondbacks organization. He's 7-5 with a 2.70 ERA and 1.08 WHIP, striking out 109 batters in 106.2 innings.
Perez, 25, has spent the 2018 season in Triple-A Reno. He's hitting .284/.342/.417 with six home runs and 29 runs batted in.