Before one can firmly answer such a question lets first define the Work Function (WF) and the Contact Potential Difference (CPD).
Let’s start with the notion of work function since it is commonly misunderstood. The meaning of WF evolved over time, and some people missed the change.
Work function
Definition
The definition of work function is that it is a minimum energy necessary to remove an electron from the bulk of a material through a given surface.
A common representation of the WF as the energy difference between the lowest vacuum state and the Fermi level of the material is often incorrect.
Tungsten work functions
During development of electron microscopy, It has been discovered in 1936 that a single tungsten crystal shows anisotropic emission of electrons when heated.
Some crystallographic faces of tungsten emitted electrons only at very high temperatures of 2000 K while others were active even at 700 K.
It may come as a surprise since the Fermi level for a given crystal in equilibrium is uniform across the crystal and so is the energy difference between the lowest vacuum level and the most energetic electrons within the metal. So, should be the work function defined as the difference!
Yet electrons poured out easier in some directions than in others.
Namely, work function depended on the surface orientation with respect to the crystal lattice.
A Tungsten monocrystal has a single Fermi level, there is only one lowest vacuum level and still experiment shows several distinct work functions!
In the picture below a tungsten monocrystal is depicted. Red, green and blue lines connect centers of (100), (110) and (111) faces, respectively.

The faces are denoted by vectors orthogonal to them. For example, the crystallographic face (100) is parallel to the YZ plane because the $[1, 0, 0]$ vector is orthogonal to that plane.
The work functions are:
Face | Work function [eV] |
100 | $\Phi _{100} = 4.63 $ |
110 | $\Phi_{110}= 5.25$ |
111 | $\Phi_{111}=4.47$ |
Surface dipole
The reason why work function varies depending on the surface orientation is so called surface dipole. This is an energy barrier experienced by mobile electrons at the surface.
There are several known causes for the barrier:
quantum tunneling (important in metals)
surface states with energies in energy gap (semiconductors)
“smoothing” effect (opposite dipole sign to tunneling)
surface adsorbates
…
They all result in a mismatch in density distributions for positive and negative charges. Here, just tunneling will be considered.
Surface dipole due to tunneling
The plot below shows positive (red) and negative (blue) charge densities $\rho(x)$ at the surface of a metal.

Both densities vanish at the material surface into the vacuum, but the electron density does it slower.
This is due to the fact that electrons are much lighter than nuclei and their wave functions will extend further into the vacuum.
One can see that imbalance of the densities will form excess of positive charge just below the surface and excess of negative charge just outside of it. In other words, an electric dipole is formed.
The dipole generates an electric field in a thin layer surrounding the crystal. The electric field will point outwards the surface thus producing an electric potential barrier for the electrons crossing the surface.
In short, the surface dipole will prevent low energy electrons from escaping the material.
The height of the surface potential barrier will depend on the density of lattice sites on the surface. Thus, crystal faces that have more lattice sites per unit surface area will tend to show stronger repulsion towards carriers from the bulk.
Although the width of the dipole layer (i.e., the width of electron charge density tail) is very small and does not exceed the lattice constant of the crystal, the resulting potential barrier is macroscopic and extends into the vacuum like $\propto \frac{1}{r^2}$, where $r$ is the distance from the surface.
Work function for positive dipole
The graph below depicts an electric potential experienced by an electron on its path to freedom.
In the bulk, electrons have energies of up to Fermi level $E_F$.
In vacuum, the lowest energy state has energy $E_{vac}$. If a single electron is brought from the vacuum to the bulk,
the energy $|\mu|$ would be released. This is by definition, a chemical potential. $\mu$ is negative if the energy is released and positive if it needs to be delivered.
The surface dipole manifests itself in the surface dipole potential $V_{sdp}$.

An electron in the bulk of the material would need to gain at least
$$\Phi=-\mu + V_{sdp}$$
of energy in order to escape to vacuum. And this the work function.
A word of caution.
The potential plotted above is one-dimensional. It is so, because electron’s trajectory is one-dimensional.
It is important to keep in mind that the trajectory is submerged in a three-dimensional space. Only 3D electric fields can produce such a potential from the surface dipole on a finite surface. A 1D dipole can generate only an step-function potential. That means that in 1D the surface dipole potential does not decay to zero with the growing distance from the dipole and $ \Phi=-\mu$ .
Work function for negative dipole
The positive dipole due to the different tunneling capabilities of positive and negative charges raised the energy barrier for electrons at the surface. It is also possible to engineer metal surface with a negative surface dipole.
One mechanism is discussed in the R. Smoluchowski article.

In the case the surface dipole potential is negative or zero the numerical value of the work function is given by
$$
\Phi = -\mu.
$$
Here the work function is actually equal to the difference between the lowest vacuum level and the Fermi level.
Field effect and the work function
t.b.c.
Contact Potential Difference
The Contact Potential Difference (CPD) is a surprisingly elusive concept. It took me years to come to terms with it.
To my defence, it has been a subject to fight over for giants of 19th century physics: J.J. Thompson (later Lord Kelvin) and J.C. Maxwell.
I would argue, that they had it easier back then, because they didn’t have to deal with so much of confusing literature on the subject 🙂.
I will use a historical approach here.
Separate conductors
Suppose you have two electrically neutral conductors: one made of Zinc the second of Copper.
The electric neutrality is easy to achieve by temporarily grounding them before the experiment.

Since both metals are neutral, they produce no electric field outside, nor inside. Thus the difference in electric potentials between points A and B is zero. The points are just above the surface of metals.
Conductors in contact
What was discovered by Volta in late 18th century is that after the metals start touching each other as in the picture below

a permanent potential difference of about 0.75 V develops between points A and B. This phenomenon is called Volta effect and the potential difference is known as Contact Potential Difference or CPD in short.
Attempt at an explanation
Please, notice the the points A and B hoover above the surface of metals and do not touch the surface.
So, lets summarize what we know:
- In the connected metals, electrons are in an equilibrium and no net electric currents are flowing.
- Still, experiment shows that there is a potential difference above the metals.
- Potential difference above the metals must come from potential difference inside the metals.
- Potential difference inside a conductor should generate a current …
And here we are. In a contradiction.
Could it be that the freshly developed CPD is just compensated by a preexisting potential difference of opposite sign?
Nope. There was no potential difference between A and B before metals were brought to contact.
What would happen in the two metals were separated again? Will the potential difference go back to zero?
Nope. Such experiments have been performed and they show that after separation the metals are no longer neutral.
The phenomenon is know in the literature as contact electrification and consists on charging two neutral conductors made of different metals just by bringing them to a short contact.
Do not confuse contact electrification with charging due to rubbing! Charge transfer due to the rubbing of different materials is called the triboelectric effect and it is carefully avoided in contact electrification experiments.
That means that the charges from one metal do move to the other, so the potential difference is really developed.
So, why the currents do not flow, then?
You can imagine the two metals before contact as containers of electrons. In Zinc, the electrons have larger kinetic energy than in copper. Upon contact the energy of the electrons in both containers equilibrate. But the equilibrium is achieved for full energy: kinetic + potential. Thus, some tiny fraction of hot electrons from Zinc will go to Copper and rise the potential energy of electrons there. At the same time, the potential energy in Zinc will be lowered.
So, the wisdom nr. 4 from the list above is not universal. It is possible to have gradient in electric potential inside the conductor and no currents at the same time. This is the case when the gradient overlaps with an opposite gradient of kinetic energy.
This process stops once Fermi levels of Zinc and Copper equalize.
Kelvin probe
Measurement circuit
The Kelvin probe circuit is essentially depicted below:

See the voltmeter post if you want to grasp why such a circuit is inevitable.
Here, the two metals are in electric contact through an ammeter, so their Fermi levels match. The Copper plate oscillates above the Zinc creating a variable capacitor $C$. The electric potential between the plates is just $CPD$!
One can recover it by measuring current $I$ due to the oscillations from the formula
$$
I = CPD\frac{\text{d}C}{\text{d}t}.
$$
Thus, the Kelvin probe measures CPD.