In the text we say
'yum is "waiting for a lock". This can occur when azure extensions are still running in the background'
This suggests that the script will fail sometimes for this reason.
Is there any way we can either check that azure extensions are finished or catch the lock error and act accordingly?