@Override
    public Iterable<DiscoveryNode> discoverNodes() {
        try {
            Collection<AzureAddress> azureAddresses = azureClient.getAddresses();
            logAzureAddresses(azureAddresses);
            List<DiscoveryNode> result = new ArrayList<>();
            for (AzureAddress azureAddress : azureAddresses) {
                for (int port = portRange.getFromPort(); port <= portRange.getToPort(); port++) {
                    result.add(createDiscoveryNode(azureAddress, port));
                }
            }
            return result;
        } catch (NoCredentialsException e) {
            if (!isKnownExceptionAlreadyLogged) {
                LOGGER.warning("No Azure credentials found! Starting standalone. To use Hazelcast Azure discovery, configure"
                        + " properties (client-id, tenant-id, client-secret) or assign a managed identity to the Azure Compute"
                        + " instance");
                LOGGER.finest(e);
                isKnownExceptionAlreadyLogged = true;
            }
        } catch (RestClientException e) {
            if (e.getHttpErrorCode() == HTTP_FORBIDDEN) {
                if (!isKnownExceptionAlreadyLogged) {
                    LOGGER.warning("Required role is not assigned to service principal! To use Hazelcast Azure discovery assign"
                           + " a role to service principal with correct 'Read' permissions. Starting standalone.");
                    isKnownExceptionAlreadyLogged = true;
                }
                LOGGER.finest(e);
            } else {
                LOGGER.warning("Cannot discover nodes. Starting standalone.", e);
            }
        }  catch (Exception e) {
            LOGGER.warning("Cannot discover nodes. Starting standalone.", e);
        }
        return Collections.emptyList();
    }
@Test
    public void discoverNodes() {
        // given
        AzureAddress azureAddress1 = new AzureAddress("192.168.1.15", "38.146.24.2");
        AzureAddress azureAddress2 = new AzureAddress("192.168.1.16", "38.146.28.15");
        given(azureClient.getAddresses()).willReturn(asList(azureAddress1, azureAddress2));

        // when
        Iterable<DiscoveryNode> nodes = azureDiscoveryStrategy.discoverNodes();

        // then
        Iterator<DiscoveryNode> iterator = nodes.iterator();

        DiscoveryNode node1 = iterator.next();
        assertEquals(azureAddress1.getPrivateAddress(), node1.getPrivateAddress().getHost());
        assertEquals(azureAddress1.getPublicAddress(), node1.getPublicAddress().getHost());
        assertEquals(PORT1, node1.getPrivateAddress().getPort());

        DiscoveryNode node2 = iterator.next();
        assertEquals(azureAddress1.getPrivateAddress(), node2.getPrivateAddress().getHost());
        assertEquals(azureAddress1.getPublicAddress(), node2.getPublicAddress().getHost());
        assertEquals(PORT2, node2.getPrivateAddress().getPort());

        DiscoveryNode node3 = iterator.next();
        assertEquals(azureAddress2.getPrivateAddress(), node3.getPrivateAddress().getHost());
        assertEquals(azureAddress2.getPublicAddress(), node3.getPublicAddress().getHost());
        assertEquals(PORT1, node3.getPrivateAddress().getPort());

        DiscoveryNode node4 = iterator.next();
        assertEquals(azureAddress2.getPrivateAddress(), node4.getPrivateAddress().getHost());
        assertEquals(azureAddress2.getPublicAddress(), node4.getPublicAddress().getHost());
        assertEquals(PORT2, node4.getPrivateAddress().getPort());
    }