Allegri lauds Milan's mental strength
Valter Birsa's 22nd-minute goal at the San Siro saw Milan to just their third Serie A victory of the campaign.
Milan had conceded 13 goals in their previous seven league matches and the clean sheet pleased Allegri.
"We were concentrated in defence, having conceded 13 goals in the previous seven rounds," Allegri told Sky Sport Italia.
"We did well to remain solid and tight. When our team is so compact, it becomes difficult for opponents to break through."
The clean sheet came with 21-year-old Brazilian goalkeeper Gabriel making his Serie A debut after Christian Abbiati picked up a calf injury on the morning of the game.
Allegri felt his side were worthy winners and said they were wasteful with their opportunities on the break in the first half.
"It is normal that with so many players out of action, and we lost the goalkeeper this morning, there were question marks," Allegri said.
"We played well in the first half and wasted a few too many counter-attacks, but then we created more chances after the break and it was a deserved victory.
"Even if he missed a lot of chances, M'Baye Niang got himself into the right positions, while it was important to have Kaka come in at a time when we were struggling physically and psychologically."
Allegri, whose side face Barcelona in the UEFA Champions League on Tuesday, backed Alessandro Matri to end his goalless run.
The forward is without a goal since returning to Milan from Juventus in August.
"It's never easy to play as a centre forward, but he fought hard, had a few opportunities and will find the goal soon," Allegri said.
"The important thing is that he doesn't let his head drop, as he has always scored goals and will do again."