Although this medieval, I will put it in contemporary Urban Planning terminology, as many successful medieval cities were successful on less-than-perfect locations, but this is to define the 'sweet spot' for your story. And I'm an Urban Planner. I'd love to address what's inside your city as well (civic and community facilities distribution, etc.), but that's for a different question, isn't it?
Transportation & Communication
Critical to the growth of a successful city is a collection of meaninful connections, in this case most likely easily-traveled roadways. Which means, while you may have a mountain backdrop for protection or scenery, you should have pathways to allow transporation, trade, and commerce to access your city: so a mountain pass, a land-bridge (if you're an island) or scattered oases (if you are in the desert), a river if you're inland. Being central and accessible puts you as the pinnacle of trade and boosts your city.
Access to clean, plentiful water is a necessity, not just for food, but for water distribution. A fast-flowing, non-seasonal (you don't want floods) river can run through or adjacent to your city. It provides nominal protection, some food, and hygiene. If you insist on a desert city, consider qanats from nearby mountains.
Wastewater and Stormwater Management
Integral to the success of a city is a place to dispose of wastewater and sewerage; most likely this would be your river mentioned before. For stormwater, place your city at a higher elevation, with a gentle slope to the river or sea. You'll notice in any older city (London, Rome, Kaifeng, etc.) that when you're in the old-town areas, you can find your way to the river by just walking downhill.
This is internal to your city, so not directly part of your question, but it addresses your city's location. There's a well-accepted understanding that a major city has a theoretical (not literal) radial arrangement with the smaller settlements. This is called Central Place Theory. You want to be the big city, so distribute the medium and smaller ones along this theory (not literally) around your city.
[radial], [centers of academia and governance], [well distributed comm facs]
This may be the most important. Your city should have access to farmland (down-river to receive the urban sewerage and so as not to put livestock waste through the city) and hunting areas (up-river, as the goods are sent by raft down-river to town). Almost any geographical feature, from swampland to mountains to water features can support the town and be used for protection from outside threat. Just ensure you have access through these harsher areas for trade.