Question

We have a fairly complex system we're developing involving a few different applications (MVC, http-based WCF, TCP-based WCF, ADFS, and some generic Worker Roles), all deployed to Azure. For local debugging, we need these to run in the local Dev fabric as well as IIS. I've accomplished pretty much everything I need to and it all works, with the exception of one thing: I can't predict what IP address various things will bind to in the Dev Fabric. Sometimes it's 127.0.0.1, sometimes it's 127.0.0.3, and sometimes it's 127.0.0.4 (and maybe some others?). For my config file transforms and ADFS relying-party trusts, I need to know what these IPs will be in advance.

How do I manage/control (or at least predict) these IP addresses specifically for my web site? (WCF is all good) If I can actually get everything deployed to my dev fabric with the proper IPs being referenced, then everything works! However, it's very cumbersome to do and takes several tweaks to web.config and app.config transformation files every single time I need to (not to mention reconfiguring the ADFS server every time it changes), so this isn't a sustainable situation by any means!

Was it helpful?

Solution

We had a similar challenge with an ASP.NET MVC solution that uses a second web role running a WIF STS for Claims-Based Authentication. The web.config of the MVC application needed to know the non-load balancer IP address of the STS when running in the local emulator.

In addition, we have custom code building URL routes that only sees the internal IP address (127.255.0.X) assigned by the emulator. These routes would cause problems when passed back through the load balancer. We also shutdown the Default Web Site in IIS to guarantee the port remapping done by the emulator.

With the Azure 1.8 SDK, we observed the local emulator would consistently assign the 127.255.0.X addresses when the application was started from the command line and all other deployments in the dev fabric were removed.

We built a PowerShell script to startup the Web Roles from the command line once the solution was packaged inside VS2010. We have a build configuration and web transformation called AzureLocal we use to package for the local emulator.

Import-Module WebAdministration
Stop-WebSite 'Default Web Site'

$env:WindowsAzureEmulatorInstallPath = (Get-ItemProperty -Path "Registry::HKLM\Software\Microsoft\Windows Azure Emulator" -Name InstallPath).InstallPath
$env:ServiceHostingSDKInstallPath = $env:WindowsAzureEmulatorInstallPath + '.NET SDK\2012-10'

$env:Path = $env:WindowsAzureEmulatorInstallPath + 'emulator;' + $env:WindowsAzureEmulatorInstallPath + 'devstore;' + $env:ServiceHostingSDKInstallPath + 'bin;' + $env:Path

csrun /devfabric:start
csrun /devstore:start
csrun /removeAll
csrun /devfabric:clean

csrun Application\Foobar.Extensions.Azure\csx\AzureLocal Application\Foobar.Extensions.Azure\bin\AzureLocal\app.publish\ServiceConfiguration.Local.cscfg

Write-Host "Application Pools to Attach for Debugging"
get-item IIS:\AppPools\*

$ie = New-Object -ComObject InternetExplorer.Application
$ie.Navigate("https://127.255.0.1:444")
$ie.Visible = $true

Your applications sounds to have more moving parts than our STS and MVC combination, but if you can script the startup outside Visual Studio then you can get predictable address assignment.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top