Two ways you could do this.
1) Since you have to publish to Azure use transforms http://msdn.microsoft.com/en-us/library/dd465326(v=vs.110).aspx
2) if that isn't possible, get the Host from the Request object: if(Request.Url.Host == "localhost") do localhost connection else do azure connection
Of the two, I'd recommend the transforms.