Investor enthusiasm for Inc (AMZN.O) is pretty consistent: the stock tends to rise, even though the company isn't consistent about making profits.

On Thursday, it posted second quarter profit of $92 million on sales of $23.19 billion, only its third quarterly profit since the first quarter of 2014. Amazon has reported an annual net profit in 10 of its 18 years as a public company, and only twice in the last four years. On Friday, Amazon shares closed at a record high of $535.50 and the company passed Wal-Mart (WMT.N) in market value.

Though some investors have expressed concern about the uneven results, Amazon said Thursday, as it has in the past, that the online retailer will invest on everything from its cloud computing business to gadgets like the Kindle, without worrying about quarterly results. 

"This (profit) is more of an anomaly because they operate on a mindset that if there's profit they're not being creative enough," said Michael Yoshikami, CEO of Walnut Creek, California-based Destination Wealth Management, which has $1.5 billion under management and doesn't hold Amazon. "They're a huge capex, infrastructure company and obviously there's lot of things they can spend their money on."

One area that excites Wall Street for its profit-making possibilities is its cloud computing business, Amazon Web Services, which has more than 1 million active customers in 190 countries and is planning to expand to India. The division's revenue rose more than 80 percent in the second quarter to $1.82 billion and Amazon said it had an operating profit margin of 21.4 percent.

Amazon has consistently logged strong top-line growth but has plunged most of it back into large investments to expand its distribution network, add original media content to Prime -- its $99-a-year membership program -- and spend heavily on developing unpopular devices like the Fire smartphone.

"You can see a lot more upside" with AWS, said Tuna Amobi, an equity analyst with S&PCapital IQ in New York, adding that the business, which generated more than $5 billion in revenue in 2014, could double in size in two years.  

Asked whether Amazon's swings in profitability would stabilize in the future, Amazon CFO Brian Olsavsky admitted its performance was "lumpy" and told analysts on Thursday, "We will continue to work on both those tracks going forward."

The online retailer also faces new competition and may need to ramp up spending in areas like fulfillment, analysts said. This week,, an e-commerce company headed by a former Amazon executive, made its site available to the public, promising savings on millions of items for a membership that is half the price of Amazon Prime.

The question for Wall Street is whether it will be patient with how the company spends its money despite uneven profits. The immediate answer appears to be yes.

Buoyed by strong growth in AWS and bullish comments on Amazon Prime, at least 24 brokerages raised their target price on the stock. Of the 43 analysts covering the stock, 34 have "buy" or higher ratings, according to Thomson Reuters data.