Portugal took the lead against Azerbaijan in comical circumstances as goalkeeper Shahrudin Mahammadaliyev punched a cross against captain Maksim Medvedev and in to his own net.