Retrieve Customer address by address id Magento 2.

You can get the customer address details by address id in Magento 2.

When you need a Customer address object and if you have address id available for the customer address, You can get the address data using the getById() method from the Magento\Customer\Api\AddressRepositoryInterface.

Simple Code snippet to fetch Customer address data using Model Class,

<?php
namespace Jesadiya\Address\Model;

use Exception;
use Psr\Log\LoggerInterface;
use Magento\Customer\Api\Data\AddressInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Customer\Api\AddressRepositoryInterface;

class CustomerAddressById
{
    /**
     * @var AddressRepositoryInterface
     */
    protected $addressRepositoryInterface;

    /**
     * @var LoggerInterface
     */
    private $logger;

    public function __construct(
        LoggerInterface $logger,
        AddressRepositoryInterface $addressRepositoryInterface
    ) {
        $this->logger = $logger;
        $this->addressRepositoryInterface = $addressRepositoryInterface;
    }

    /**
     * Retrieve customer address.
     *
     * @param int $addressId
     * @return AddressInterface
     * @throws LocalizedException
     */
    public function getCustomerAddress($addressId)
    {
        $addressRepository = null;
        try {
            $addressRepository = $this->addressRepositoryInterface->getById($addressId);
        } catch (Exception $exception) {
            $this->logger->error($exception->getMessage());
        }

        return $addressRepository;
    }
}

Pass Customer address id as a parameter to fetch specific customer address,

$addressId = (int)1;
$customerAddress = $this->getCustomerAddress($addressId);
var_dump($customerAddress);

Output:
Customer address data from the AddressInterface.