The 20-year-old striker has hit 10 goals in 13 games this season, taking him to the top of the Serie A scoring charts.
El Shaarawy, who also scored in Wednesday's 3-1 win over Anderlecht, said that Allegri's faith in his ability is paying dividends for the Rossoneri, who have otherwise struggled so far this campaign.
"I didn't start the season well," the Italian international told La Repubblica. "However, Allegri still showed great faith in me and that was very important.
"Allegri asks me to perform well, he doesn't ask me for goals. Helping the side defend is a sacrifice that is eventually repaid and it's no coincidence that the goals have arrived.
"This is a fantastic period for me, but I have to continue on this road."
Milan sit 12th in the league table.