How to Deploy WCF Service to Windows Azure?

From the book I co-authored, Beginning Windows Phone 7 Development, you will notice in Chapter 3 you will be asked to build Windows Phone 7 Notepad application using Azure as your backend and service tier. Unfortunately, since the book was written Microsoft recently updated the UI of the Azure using Silverlight (Go Silverlight Smile ).

This blog will take you through the Azure’s new interface to deploy WCF Service.

Also if you must you can always go back and forth to new and old by clicking on the link below that says take me back to the old portal as shown below and the Chapter 3 instruction from the book will be still valid Smile

SNAGHTMLa5c5eb8

Deploying WCF NotepadService as New Hosted Service

At the end of the blog you will find the source code to the NotepadService and I wont go in detail on how to create WCF service and I will simply use the already created WCF Azure service.

  • Open NotepadService in Visual Studio 2010.
  • From Solution Explorer Right Click on NotepadService project and choose Publish.
  • Choose Create Service Package Only and Click OK as shown below.

SNAGHTMLa4501ab[6]

  • Windows Explorer will open and you will see NotepadService.cspkg and ServiceConfiguration.cscfg which you will be deploying to Azure.
  • Go to https://windows.azure.com/ and log in.
  • When you log in on upper left click New Hosted Service as shown below

image

  • When prompted with Create a new Hosted Service as shown below fill in following information. 1) From Choose a subscription dropdown you will see multiple if you bought multiple Azure accounts. 2) Enter a name for your service 3) Enter a URL prefix that you will be using to connect to your NotepadService  4) Choose Anywhere in US or if you want to be closer to your database create or choose existing affinity group 5) Choose Deploy to stage environment 6) Typically on Deployment name I use version number 7) Choose NotepadService.cspkg and ServiceConfiguration.cscfg.
  • You will receive warning message box for now simply click ok as shown below. Warning has to do with the fact that you only have one instance but you can easily increase this later time.

Warning
A warning has been encountered
A warning has been encountered.  Click “See more details” to see the warning.  Would you like to override and submit?

Warning: This deployment has at least one role with only one instance. We recommend that you deploy at least two instances per role to ensure high availability in case one of the instances becomes unavailable. Doing so also enables coverage of the Windows Azure Compute SLA (http://go.microsoft.com/fwlink/?LinkID=159704&clcid=0x409), which guarantees 99.95% uptime. For more information please visit http://go.microsoft.com/fwlink/?LinkID=202707 (http://go.microsoft.com/fwlink/?LinkID=202707).  Find more solutions in the Windows Azure support forum (http://go.microsoft.com/fwlink/?LinkID=206235).

image

  • You will see following where NotepadService is being deployed to the staging.

SNAGHTMLa5a3ac4

Eventually, when the deployment is done you will se the service being started in the status column.

About the Deployed Service

When you click on 1.0.0.0 on right side you will see many useful information and one of them is DNS name which you can click and view your service. Also another useful information is IP of the service as well if you are planning to create A pointer or use CNAME to point to your staging. See below for the figure.

image

Going from Staging to Production and Visa Versa

One of thing you will one to do is going from staging to production and production to staging in order to do this you must first deploy your service to staging and to production because by doing this you receive VIP ( virtual IP) that allows your to SWAP your staging IP to production imp or visa versa. This is nothing more then the networking trick.

  • From above you deployed to staging and to deploy to production you can simply click on 1.0.0.0 staging and you will see New Production Deployment Button is enabled top left as shown below.

SNAGHTMLa8827b2

  • When prompted with the Windows just redeploy NotepadService again as shown below.

image

  • When click ok you will be prompted with warning again regarding the one instance as shown below. Click ok and ignore this warning.

image

  • When the status changes to Initializing click on 1.0.0.0 Production and you will see Swap VIP is enabled and same thing happens when you click 1.0.0.0 staging as see below figure.

SNAGHTMLa8bc596

  • When you click on Swap VIP now you have ability to move production to staging or staging to production simply by changing VIP seen below.

SNAGHTMLa8c8c1f

In this section you learn about moving from production to staging or staging to production via VIP swapping which is simple networking trick all done by Azure behind the seen. and Making it seamless to the Azure developers like yourself Smile

Download Code

Conclusion

This blog is somewhat of supplementary information to Beginning Windows Phone 7 Development Chapter 3 specific to the new Azure UI. Hopefully this will help the reader.

About toetapz

Henry Lee is founder of NewAgeSolution.Net and is passionate about the technology. He is also the author of the book Beginning Windows Phone 7 Development 2nd from Apress (http://www.apress.com/9781430235965). He works with various Fortune 500 companies delivering mobile applications and rich internet applications. He recently formed start-up company called ToeTapz.com focusing his energy on delivering mobile applications in Windows Phone 7, Android and iPhone. In his spare time, he dedicates his effort to help his .NET community by delivering sessions at the technology events. He enjoys talking with other technologist about current trends in the technology and sharing business insights with fellow colleagues. Often you will find Henry at local cigar bar enjoying a cigar and a drink trying to come up with next big mobile application.
This entry was posted in Azure, WCF, Windows Phone 7 and tagged , , . Bookmark the permalink.

8 Responses to How to Deploy WCF Service to Windows Azure?

  1. Pingback: Tweets that mention How to Deploying WCF Service to Windows Azure? | Toetapz's Blog -- Topsy.com

  2. Pingback: Apress’ “Beginning Windows Phone 7 Development” — Global Nerdy

  3. Daz says:

    I got your book and I’ve tried the example and I’ve tried developing my own version and whether i try to run it locally or deployed to Azure I get the following error message (with slight variation of endpoint depending on what I’m doing).

    Do you have any ideas ?

    There was no endpoint listening at http://3fc2328b69e44a9b8372189e0fe619ed.cloudapp.net/Service1.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

    The function it fails in is in References.cs, the second line

    public System.Guid EndAddUser(System.IAsyncResult result) {
    object[] _args = new object[0];
    System.Guid _result = ((System.Guid)(base.EndInvoke(“AddUser”, _args, result)));
    return _result;
    }

    • toetapz says:

      1. Can you directly go to http://3fc2328b69e44a9b8372189e0fe619ed.cloudapp.net/Service1.svc in your browser?
      2. If you in side company network is the company proxy blocking this domain?
      3. Is your firewall setting blocking this?

      if none of above does not help you please zip and send me your code at contact@toetapz.com.

      • Daz says:

        Thanks for replying.

        1. When entering http://09a38d6b9e434d80acb8bb395247c7f6.cloudapp.net/
        in a browser i get “Internet explorer cannot display”.

        2. I am an individual on a home network. I have McAfee installed.

        3. I am not comfortable with networks. I tried turning McAfee firewall off but still same. I tried giving all my programs full internet access. Not sure if this was what i should have done.

        I went through your example for myself, and when i ran it locally at page 63 I get the “endpoint not listening” error so i wrote a tailored version for my app but still got the same. I deployed it and got the same.

        I then downloaded your code from this website and still got the same.

        Must be something fairly simple ?

  4. Daz says:

    the other thing I have noticed is in my app, the ServiceReferences.ClientConfig file with the cloud address. The service proxy contains the local http://127.0.0.1:81/Service1.svc. Now when i try to change it to the cloud address, it says “downloading information” then it brings up an 2 errors.

    Error1 – unable to connect to remote server because the target machine actively refused XX.XX.XX.XX:80 (ip address disguised). Could this be it ? How do i fix it ?

    Error 2 -There was no endpoint listening at cloude address

  5. David Farmer says:

    I really like your notepad App that lets a phone user add records to an Azure database. But my Phone client app will not compile. It gives an error on the “ServiceClient” type in NotepadViewModel.cs saying are you sure there is a directive or reference to it.What library is it in?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s