Microsoft (MSFT -1.84%) has been on a roll the past two years -- since Feb. 2013, shares of the Windows maker have risen nearly 60%, outperforming the broader S&P 500 by a fair amount.

But recent performance has been far less impressive -- over the last month, shares are down nearly 6% (compared to a 4% gain for the S&P 500). Does the pullback represent a buying opportunity? Or should investors avoid the PC giant?

Microsoft valuation appears reasonable
Microsoft currently trades at a trailing price-to-earnings ratio of around 17 times, basically in line with the broader market. The valuation seems fair, given that the business is both mature and stable: Last quarter, Microsoft posted revenue growth of around 8%, while earnings per share declined only modestly. 

Microsoft continues to pay a reliable dividend, yielding about 2.8% at current levels. With about $90 billion on its balance sheet, the company has enough cash to keep its payout steady for the foreseeable future.

But it is going through a transition
Its business, however, is somewhat uneven. Emerging cloud products are seeing strong demand, but its legacy Windows business is floundering.

In the second quarter, Microsoft Windows revenue fell 13% year-over-year. Businesses remain loyal to the operating system, but consumers are increasingly uninterested. In an effort to compete with low-cost mobile devices, Microsoft has also begun giving its hardware partners discounts on Windows licenses for select devices.

While that is good for the health of the broader Windows ecosystem, it appears to be taking a toll on financial results. Windows 10, expected to debut later this year, could reinvigorate the Windows ecosystem, but it is unlikely to add meaningfully to Microsoft earnings in the near term, as the company plans to give the new version away as a free upgrade to users of Windows 7 and 8.

Its cloud businesses, in contrast, are on fire. Last quarter, commercial cloud revenue rose 114% and is now on pace to have an annual run rate of $5.5 billion. Primary cloud products include Office 365, Azure, and Dynamics CRM, all of which appear to be in strong demand. Office 365, in particular, has managed to amass 9.2 million subscribers and continues to grow rapidly (the number of Office 365 subscriptions rose 30% sequentially in the second quarter), despite facing several low-cost competitors.

Its hardware efforts have not produced anything of significance -- Windows Phone is largely irrelevant, and the Surface is a small business -- but Microsoft has never been driven by its hardware sales.

More upside could be in store if its cloud businesses continue to scale
At these levels, Microsoft shares appear to be a fairly safe bet. The Windows business remains challenged, but enterprise customers are loyal, and Windows 10 brings the promise of an upside surprise.

Longer term, the real potential for Microsoft shareholders appears to lie with the future of its cloud products. Demand has been robust so far, but competition is fierce, and long-term success is far from guaranteed.

Still, investors could do worse than Microsoft. While it may not repeat its impressive performances of 2013 and 2014, given its valuation and its dividend, Microsoft is the sort of technology stock that would fit in nearly any portfolio.