Foremost it depends on your citizenship....Americans apply for the position with the Department of State. Working for a consulate or Embassy requires the following:
1) Good to great grades
2) Ability to pass a background and security clearance check
3) No outstanding student loans or taxes
4) Ability to pass a civil service test
5) College degree, special skill (foreign language, etc), and/or experience
Often a country will hire a local contractor or native to perform/provide certain services and duties. For example, the Canadian Government contracts many United States citizens to staff their consulate offices. The United States government hires "locals" as well to staff the various foreign posts worldwide.
The difference between an Ambassador or consulate representative is the difference between night and day. To become an Ambassador you will (in most cases)need to be a successful business person with a connection to that particular country and connection with the President....As mentioned, that usually involves large donations to the party and its candidates over a period of time....Sometimes, just being a solid business leader and knowing political leaders on both sides is just as good....(Usually being a top business leader goes hand in hand with being involved in the political process).....Another way to become an Ambassador is to be a career diplomat or former executive branch appointee.
A consulate representative is very much a different position. There are consulate representatives, and in some locations, a position called Consul General....A Consul General is also often a business leader or a person with strong ties to the President. A Consul General is the head of the consulate office for that region. A Consul General (CG) position is often a great gig (for the prime postings) in countries like Britain, Canada, Italy, France, Germany, etc....In prime postings, a CG gets all the perks (i.e. driver, security, residence, expense account, chef, etc)....
A consulate representative is an entry level position. For those who aspire to make foreign services a career, you would start out as a consulate representative, then move up to the level of Consul representative then, either CG or Ambassador to end your diplomatic career....
Foreign Services is great career paths...some parts of the world are very dangerous. Being a career diplomat can take a toll on family life, and some positions are very, very stressful without the benefit of being rewarded. The upside is your are a diplomat, and with that comes the exposure and prestige you might expect.
In a nutshell, if you are interested in becoming a diplomat, check out the Department of State website and look up key words like "foreign affairs", "foreign services", Consul General, etc....I would also encourage you to read the bio's of USA Ambassador's, both from the G-8 countries and the lesser known, like Bermuda and Iceland.....Other countries in Africa and the Middle East require a completely different set of skills and background....
Lastly, former Ambassador's write books-if you are interested in serving in a particular country, research the history and bio's of the former Ambassadors and the books they wrote......Of course you can always ask a current or former Dept of State personnel within this area as well..
Hope this helps....
They are appointed by government officials... presidents, prime ministers, etc... although to be appointed, they must be approved by Congress and Parliaments, etc.... also, a lot of times groups petition for specific members.