- when it is on its own, without a noun or adjective behind it that it modifies, it is "that": az nem jó "that is not good"
- when it is right in front of a noun, or right in front of an adjective (that might be in front of a noun or on its own), it is "the": az alma "the apple"; az új "the new one"; az új könyv "the new book"
- when it is part of az(ok) az NOUN, az(ok) a NOUN, ez(ek) az NOUN, ez(ek) a NOUN, the a(z) that is close to the noun is not translated into English, and the az(ok), ez(ek) mean "that, those, this, these": az az alma "that apple", az a könyv "that book", azok az almák* "those apples".
One tricky part is that az may be followed by an adjective and/or a noun that are acting as a predicate: Az új. "That is new."; Az a nappali. "That is the living room."
Differentiating those from az új "the new one" and az a nappali "that living room" can only be done by looking at the wider context of the sentence: is there another predicate, such as an explicit verb? Similarly, Az új könyv. could (I think) be either "That new book.", "The new one is a book.", or "That is a new book." - in which case, context outside of the sentence would be required to understand the sentence correctly.
They're identical. There's no difference in pronunciation at all.
(Longer story: once upon a time, it seems that ly did denote a distinct sound from j, but they lost the distinction over time. Now they mostly just cause a headache for everybody in spelling. Also occasionally there are a few ly words which, in a few regions, get pronounced with an l or palatalized l sound instead, which is a throwback to the old sound.)