microsoft-azure-storage/src/com/microsoft/azure/storage/CloudStorageAccount.java
private static StorageUri getStorageUri(
            final Map<String, String> settings, final String service, final String serviceEndpointName, final String serviceSecondaryEndpointName, final Boolean matchesAutomaticEndpointsSpec)
            throws URISyntaxException {
        String serviceEndpoint = settingOrDefault(settings, serviceEndpointName);
        String serviceSecondaryEndpoint = settingOrDefault(settings, serviceSecondaryEndpointName);

        if (serviceSecondaryEndpoint != null && serviceEndpoint != null) {
            return new StorageUri(new URI(serviceEndpoint), new URI(serviceSecondaryEndpoint));
        } else if (serviceEndpoint != null) {
            return new StorageUri(new URI(serviceEndpoint));
        } else if (matchesAutomaticEndpointsSpec) {
            final String scheme = settings.get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME);
            final String accountName = settings.get(CloudStorageAccount.ACCOUNT_NAME_NAME);
            final String endpointSuffix = settings.get(CloudStorageAccount.ENDPOINT_SUFFIX_NAME);
            return getDefaultStorageUri(scheme, accountName, getDNS(service, endpointSuffix));
        } else {
            return null;
        }
    }
private static StorageUri getStorageUri(
            final Map<String, String> settings, final String service, final String serviceEndpointName, final String serviceSecondaryEndpointName, final Boolean matchesAutomaticEndpointsSpec)
            throws URISyntaxException {
        String serviceEndpoint = settingOrDefault(settings, serviceEndpointName);
        String serviceSecondaryEndpoint = settingOrDefault(settings, serviceSecondaryEndpointName);

        if (serviceSecondaryEndpoint != null && serviceEndpoint != null) {
            return new StorageUri(new URI(serviceEndpoint), new URI(serviceSecondaryEndpoint));
        } else if (serviceEndpoint != null) {
            return new StorageUri(new URI(serviceEndpoint));
        } else if (matchesAutomaticEndpointsSpec) {
            final String scheme = settings.get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME);
            final String accountName = settings.get(CloudStorageAccount.ACCOUNT_NAME_NAME);
            final String endpointSuffix = settings.get(CloudStorageAccount.ENDPOINT_SUFFIX_NAME);
            return getDefaultStorageUri(scheme, accountName, getDNS(service, endpointSuffix));
        } else {
            return null;
        }
    }
Gets the {@link StorageUri} using specified service, settings, and endpoint.

@param settings
A <code>java.util.Map</code> of key/value pairs which represents
the connection settings.
@param service
A String that represents the service's base DNS name.
@param serviceEndpointName
The service endpoint name to check in settings.
@param serviceSecondaryEndpointName
The service secondary endpoint name to check in settings.
@param matchesAutomaticEndpointsSpec
Whether the settings match the automatic endpoints specification.
@return The {@link StorageUri}.
@throws URISyntaxException