class AzureStorage {

    public Optional<String> findStorageAccountIdInVisibleSubscriptions(AzureClient client, String account) {
        Optional<StorageAccount> storageAccount = client.getStorageAccount(account, Kind.STORAGE_V2);
        LOGGER.debug("checking current subscription for storage account");
        if (storageAccount.isPresent()) {
            return storageAccount.map(HasId::id);
        }

        List<String> subscriptionIds = client.listSubscriptions().stream().map(Subscription::subscriptionId).collect(Collectors.toList());
        LOGGER.debug("Checking other subscriptions for storage account: {}", String.join(",", subscriptionIds));
        for (String subscriptionId : subscriptionIds) {
            Optional<StorageAccountInner> storageAccountInner = client.getStorageAccountBySubscription(account, subscriptionId, Kind.STORAGE_V2);
            if (storageAccountInner.isPresent()) {
                return storageAccountInner.map(s -> s.id());
            }
        }

        return Optional.empty();
    }

}