The title showdown will be a repeat of the Australian Open final in January when Azarenka won her first Grand Slam title with a crushing 6-3 6-0 victory over Sharapova.
"I can't play, I can't push," a tearful Ivanovic told the chair umpire before withdrawing from her match in the last four.
Ivanovic had taken a medical time-out after the ninth game of the first set before returning to the court for two more games, and exiting with Sharapova 30-0 up on her serve.
"After the treatment, it was just getting worse and worse rapidly," the 24-year-old Serb later said. "We taped it and then I tried to continue, but at the end, I couldn't even return.
"I'm very disappointed ... I really felt like I have been playing the best tennis probably played in a very, very long time".
Sharapova, champion here in 2006, lost serve in the second game of the match but she broke back in the third and seventh games before clinching the set in just over an hour when Ivanovic hit a forehand long.
"It was unfortunate that it had to end this way," the Russian former world number one said of Ivanovic's injury. "I thought towards the end of the second set we started playing really good, high quality tennis."
Sharapova was delighted, though, to advance after a relatively short match before taking on the game's hottest player in the final.
"She (Azarenka) is definitely the one to beat right now, someone who playing with a lot of confidence and all the momentum in the world," the Russian smiled. "I'd love to get my revenge from Australia and play much better, as well."
Sharapova and Azarenka will contest the final in California in a battle of the current top two seeded competitors, after the Belarusian defeated Germany's