After a bit of messing around I believe I have gotten this to work. I am sure it is messy and I am not sure if it is interfering with anything else.
<div class="single-post-thumb">
<?php if (get_post_meta($post->ID, 'az-post', true) ) { ?>
<a href="https://www.amazon.com/dp/<?php echo get_post_meta($post->ID, "az-post", $single = true); ?>?tag=myamazonid-20" target="_blank" rel="noindex, nofollow" ><?php tie_thumb( $size ); ?></a>
<?php } else { ?>
<?php tie_thumb( $size ); ?>
<?php } ?>
</div>