1

Well, I spent ages on this so I'll do something I don't normally do which is post a question and answer it in case it is helpful to someone else. If someone finds an easier way I'll gladly accept it.

Requirement: -

  • Need to access website running on azure emulator from an external device for testing.
  • Website uses oauth.
  • Website uses https only.

Problems: -

  1. Azure emulator binds to local.
  2. Google+ sign-in checks valid origin and redirect URIs.
acarlon
  • 16,764
  • 7
  • 75
  • 94

1 Answers1

1

It seems a bit crazy to go through all this just to get an external test going. Perhaps it has been one big yak shaving exercise. So, if there is an easier way, I would gladly accept it.

The solution to problem 1 is reasonably straightforward, there are a number of options, the simplest being to use netsh (assuming 33333 is some arbitrary free port that is accessible through the firewall and 44300 is the https enpoint port that azure is listening on):

C:\WINDOWS\system32>netsh interface portproxy add v4tov4 listenport=33333 connectaddress=localhost connectport=44300 protocol=tcp

This will make azure emulator think that the connection is coming from a local device.

If you are using oauth such as google+ sign-in you will still hit problem 2. This is because the host name of the redirect URL that the server sends does not match what google expects. The solution is: -

  1. Configure a domain for your local network, e.g. test.com. This is needed because google+ does not allow an IP address for the redirect URI.
  2. Edit ServiceDefinition.csdef and set the hostheader for the azure endpoint: <Binding name="Endpoint3" endpointName="HttpsEnd" hostHeader="station.test.com" /> where station is the name of the computer that azure emulator is running on.
  3. Configure google+ to accept the correct redirect URL, e.g: http://station.test.com:33333/Account/ExternalLoginCallback
  4. Run visual studio as Administrator. You need to run as administrator otherwise the hostHeader in ServiceDefinition does not work.
  5. From your external device, connect to you computer using the full name: https://station.test.com:33333

References:

Community
  • 1
  • 1
acarlon
  • 16,764
  • 7
  • 75
  • 94