如何调试Azure云项目时,将IP映射到主机名 [英] How to map IP to hostname when debugging Azure cloud projects
问题描述
试图调试在蔚蓝的模拟器我蔚蓝的Web角色时,我有一个问题。我有两个云项目和一个网站,并在调试的时候他们,负载平衡器会(当然)每次分配云项目不同的公共IP位址。
I have a problem when trying to debug my azure web roles in the azure emulator. I have two cloud projects and a web site, and when debugging them, the load balancer will (of course) assign the cloud projects different public IP-addresses every time.
该项目是相互关联的,因为IP地址几乎每一个我打F5时间会有所不同,我让他们通过主机名和域名来相互引用。这些不同的IP地址指定主机名时,问题就来了。
The projects are interconnected, and since the IPs differ almost every time I hit F5, I have them refer to one another via hostnames and dns. The problem comes when assigning hostnames to these differing IPs.
我已阅读在回答另一个类似的问题<一href=\"http://stackoverflow.com/questions/11967902/azure-compute-emulator-is-it-possible-to-control-the-ip-of-individual-instances#16814136\">Azure计算仿真:是否有可能控制单个实例的IP 的,我可以在每个运行中的云项目重写主机文件启动脚本,但我不知道如何真正做到这一点。
I have read in an answer to another similar question Azure Compute Emulator: Is it possible to control the IP of individual instances? that I could run a startup script in each cloud project to rewrite the hosts-file, but I cannot understand how to actually do it.
任何帮助吗?如何通过code访问公网IP-ADRESS负载平衡器?
Any help? How can I via code access the public IP-adress to the load balancer?
推荐答案
我们也曾经有过同样的问题,解决这个问题,我们做了以下几件事:
We too had the same problem and to solve it we did the following things:
-
限制由模拟器使用的端口数:在我们的例子中,我们也有两个服务。在
打开
并更改设置DevFC.exe.config
文件C:\\ Program Files文件\\微软的SDK \\的Windows Azure \\模拟器\\ devfabricVipPoolStartIPAddress
和VipPoolEndIPAddress
。由于我们只有两个服务,我们设定的起始地址为127.0.0.81
和结束地址127.0.0.82
。这将确保模拟器总是只使用这两个IP地址。一旦你做出这个变化,你必须重新启动计算模拟器。
Limit the number of ports used by emulator: In our case, we also had two services. Open up
DevFC.exe.config
file inC:\Program Files\Microsoft SDKs\Windows Azure\Emulator\devfabric
and change the settings forVipPoolStartIPAddress
andVipPoolEndIPAddress
. Since we had just two services, we set the starting address as127.0.0.81
and ending address as127.0.0.82
. This would ensure that the emulator would use only these two IP addresses always. Once you make this change, you have to restart the compute emulator.
<add key="VipPoolStartIPAddress" value="127.0.0.81" />
<add key="VipPoolEndIPAddress" value="127.0.0.82" />
的主机配置文件 C:\\ WINDOWS \\ SYSTEM32 \\ drivers \\ etc下
文件夹:这是我们对应的IP地址我们虚构的发展领域。这是设置看怎么样在我们的hosts文件:
Configure Hosts file in C:\Windows\System32\drivers\etc
folder: This is where we mapped the IP addresses to our fictitious development domains. This is how the settings look like in our hosts file:
127.0.0.81 svc1.mydevsite.com#服务1
127.0.0.81 svc1.mydevsite.com #Service 1
127.0.0.82 svc2.mydevsite.com#服务2
127.0.0.82 svc2.mydevsite.com #Service 2
包括 hostHeader
元素:下一个步骤是包括 hostHeader
在服务定义(.csdef)在云计算项目
文件。你必须包括 hostHeader
在绑定
部分。对于服务1,这是设置是如何看起来像csdef文件:
Included hostHeader
element: Next step was including hostHeader
in Service Definition (.csdef)
file in the cloud project. You have to include hostHeader
under the Bindings
section. For Service 1, this is how setting looks like in csdef file:
&LT;绑定名称=端点1endpointName =端点1hostHeader =svc1.mydevsite.com&GT;
<Binding name="Endpoint1" endpointName="Endpoint1" hostHeader="svc1.mydevsite.com">
这是pretty多给它尽可能设置的东西都在关注。
That's pretty much to it as far as settings things are concerned.
有这种方法的两个限制:
There are two limitations with this approach:
- 当你启动的发言权服务1模拟器,它会自动打开
http://127.0.0.81:port
,我已经去手动键入http://svc1.mydevsite.com:port
在浏览器中。 - 在我们的场景中,我始终运行的,因为IP地址在hosts文件中绑定的方式服务1,然后再服2。只有这样
服务1
势必127.0.0.81
IP地址和服务2
势必127.0.0.82
IP地址。如果我启动服务2,然后再模拟器为其分配127.0.0.81
IP地址。
- When you launch the emulator for say service 1, it automatically opens up
http://127.0.0.81:port
and I have go and manually type inhttp://svc1.mydevsite.com:port
in the browser. - In our scenario, I have to always run service 1 first and then service 2 because of the way IPs are bound in hosts file. Only then
Service 1
is bound to127.0.0.81
IP address andService 2
is bound to127.0.0.82
IP address. If I start service 2 first, then the emulator assigns it127.0.0.81
IP Address.
我敢肯定有更好的方法来完成这个事情,但这个是我们落得这样做,至今它已经为我们运作良好(至少2服务组合)。我敢肯定,如果你开始处理许多云项目,这可能会造成一些问题。
I'm sure there are better ways to accomplish this thing but this is what we ended up doing and so far it has been working well for us (at least for 2 service combination). I'm sure if you start dealing with many cloud projects, this might create some problems.
这篇关于如何调试Azure云项目时,将IP映射到主机名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!