When you're talking about gazing toward the sky, it's an adverb. You can tell because it doesn't need an object. You can just tell someone to "Look up." Also it can be followed by a preposition: "Look up at the sky." Whenever you have two words that can be prepositions that are together, the first one is functioning as an adverb.
When you "look something up", it's a preposition that needs an object.