Travellers that plan to cross Azerbaijan within a short period of time can apply for transit visas. Transit visas are valid from 3 to 5 days and costs just $20 USD for all travelers. This is the cheapest type of visa and would ideally suit those who visit Azerbaijan for just a couple of days. Transit visas are issued only through the embassies/consulates of Azerbaijan abroad. Unlike with other type of visas travelers do not need visa support from Azeri side to be able to apply for transit visas. In rare cases they might ask you in the embassy for the proof of onward travel or for the visa for your next destination after Azerbaijan.
However, the problem with transit visas are that they are issued not in every embassy/consulate of Azerbaijan and are mainly limited to the countries neighbouring Azerbaijan. In other words embassies in UK and most EU do not issue transit visas. If that is the case for you, then the only alternative is to apply for tourist visa: either electronic (evisa) or standard one.
If the transit visa has no notes or stamps about non-stop passage, the bearer has the right to stay in the Republic of Azerbaijan for not longer than five days. 5 day transit visas are $20/40 for single/double entry, are valid for one month from the date of issue. You only need an application form, passport photo and photocopy of your passport to apply for transit visa.