Windows Azure and Web Services!

So I've had a couple of questions about hosting web services (SOAP style services in the form of *.aspx pages in a Web Role or *.svc files in the form of WCF services) in Windows Azure, specifically, how to get them to work?

Now, as I've mentioned before, Windows Azure uses a design where the executing environment that your hosted service is running in is actually just a pre-configured VM running Windows Server 2008 x64 with .NET 3.5 Fx installed amongst other things. So technically, running an ASP.NET web service or a WCF service should be nothing more than adding the required components (pages) to your web role. But before you get to your VM, there is some infrastructure that you need to step across, and this is what is currently providing some challenges to running hosted web services on Windows Azure.

So right now, if you create a new web role project, add an asmx page to it, publish it to the cloud, and run the page, it will work a treat. If you then add that web reference to a client project, you will get an error. The error happens because of the way we currently configure the internal Windows Azure environment to handle internal and external comms pathways (how your external URI maps to your internal machine URI).

image

Now this is a known issue but until we release a fix, the workaround is:

1. Create your web role and add your service definition (asmx or svc component)

2. Run the project using the local development fabric

3. While the service is running, add the local reference to your client project which will generate a compliant wrapper. This is important, because if you try to add a reference to your published service, you will run into the issue above. By adding the reference against the local service, you get the service definition added to your project.

4. Now publish the service, and record the URI (should be something like https://guidforstaging_or_accountnameforlive.cloudapp.net/service.asmx_or_svc)

5. Go into your client project, and update the web service reference URI from the local address to your live address

Your service will now be able to connect to your live service and have all the information it needs to communicate without having to do the discovery process against the live environment.

Here is a quick screen cast that demonstrates the work around process.

Screencast

Also, check out the following links for more info:

Enjoy :)

Technorati Tags: Windows Azure Samples,Web Services