1. Create the depth buffer's Texture2D using the appropriate typeless format for the desired depth/stencil format (DXGI_FORMAT_R24G8_TYPELESS for DXGI_FORMAT_D24_UNORM_S8_UINT, DXGI_FORMAT_R32G8X24_TYPELESS for DXGI_FORMAT_D32_FLOAT_S8X24_UINT, DXGI_FORMAT_R32_TYPELESS for DXGI_FORMAT_D32_FLOAT)
2. Create a depth stencil view for the Texture2D using the desired depth/stencil format
3. Create a shader resource view for the Texture2D that uses an appropriate texture format based on whether you want to read the depth values or the stencil values. So for instance if you want to read depth from a DXGI_FORMAT_D24_UNORM_S8_UINT depth buffer, you would use DXGI_FORMAT_R24_UNORM_X8_TYPELESS.
4. Bind the shader resource view to the pixel shader stage, and sample it like any other texture.