0

I have an Azure project that contains a WCF Services Web Role and an ASP.NET Forms web role, I use 2 instances of each. The ASP.NET Forms web role will regularly call the WCF Services Web Role through standard service references through tcp binding configured in the Web.config like this.

<endpoint address="net.tcp://localhost:666/EventService.svc"
    behaviorConfiguration="DefaultBehaviour" binding="netTcpBinding"
    bindingConfiguration="TCPBinding" contract="EventService.IEventService"
    name="EventService" />

The problem I am having is that currently I have no way to deploy these roles without manually editing the web.config files after each deployment (because the IP endpoint addresses which these roles deploy on may change).

The way I have considered resolving this issue is by intercepting the WebRole.OnStart() event and using RoleEnvironment.Roles["MyWCFServices"].Instances, then modifying the Web.config file directly through Microsoft.Web.Administration.ServerManager to reference the correct WCF Service IP.

However before I go this route could someone please confirm there isn't an easier way to accomplish IP referencing between web roles in the Azure platform?

4

1 回答 1

1

由于 WCF 和 ASP.Net 的 Web 角色不同,它们的 url 只会因端口号而异,为什么要绑定到 IP 地址?

对于此类变体,您可以使用web.config 转换并通过创建部署配置(例如web.cloud.config.

更新:如果端点是内部的,则上述模型不适用。IP 是随机生成的,必须在运行时绑定。看到这个帖子

于 2013-07-31T08:02:52.293 回答