简体   繁体   中英

Configuring Associated WCF Web Role IP on Azure

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?

Since you have different web roles for WCF and ASP.Net, their url would only differ by port number, why do you want to bind to IP address?

For such variation you can user web.config transformation and define web.config entries for production deployment, by creating a deployment config such as web.cloud.config .

Update : If the endpoint is internal then the above model does not apply. IP gets generated randomly and has to binded at runtime. See this post

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM