Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
244 views
in Technique[技术] by (71.8m points)

c# - Accessing Azure Emulator from Another Device

I Have two different projects:

  1. Windows Phone 8 Application, which I am running on a real, physical development device.
  2. Azure Cloud service, which contains one simple WebRole endpoint that contains a ASP.NET MVC WebAPI.

My goal is simple:
Use the WP8 Application running from a real device, to access (using HTTPClient) the WebAPI controller while it is deployed to the Azure Emulator.

What DO work is:

  1. The application can successfully communicate with the WebApi when it is deployed on Azure Cloud.
  2. The application can successfully communicate with the WebApi when it is hosted locally on IIS Express (Without Azure), and the IIS Express settings are changed following this article.

As far as I understand, the problem is that the Azure Emulator is configured to listen on IP address 127.0.0.1, which is not accessible from outside the localhost domain.

I found this post that offers a solution to this exact problem, but trying to follow it results in an Unknown Exception while trying to deploy to Azure Emulator.

Is it really impossible to locally test WP8 application that communicates with Azure Cloud Service?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I figured out how it is possible to have a Phone Emulator or an attached physical Windows Phone device communicating with the Azure Emulator.

For other developers struggling with the same requirement, here are the steps required for it to work:

Assumptions:

  1. You know the IP address of the hosting machine.
  2. No Firewall is blocking the access
  3. Shut down IIS and Azure Emulators and restart them after configuration changes

Azure Compute Emulator:

  1. Open "C:Program FilesMicrosoft SDKsWindows AzureEmulatordevfabricDevFC.exe.config" for editing.
  2. Set "VipPoolStartIPAddress" and "VipPoolEndIPAddress" to your hosting machine IP (e.g. 192.168.1.100)

Azure Storage Emulator:

  1. Open both "C:Program FilesMicrosoft SDKsWindows AzureEmulatordevstoreDSServiceLDB.exe.config" and "C:Program FilesMicrosoft SDKsWindows AzureEmulatordevstoreDSServiceSQL.exe.config" for editing.
  2. Set the services section in both of the files to use hosting IP.
  3. Configure the Storage Connection String in the "Role" settings (instead of default Windows Azure storage emulator setting):
    • Right click on the Role (under "Roles" folder in the solution explorer) to enter it's Properties page. Click on Settings tab. Make sure you edit the Local settings (Select it on Service Configuration selection box).
    • Edit the Connection String for the storage
    • Manually enter credentials
    • Account name and account key are written under accounts section in DSServiceSQL.exe.config
    • Specify custom endpoints, with your hosting IP.

enter image description here

Enjoy!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...