Creating and Deploy WCF at Windows Azure Cloud and Consume it in Windows 8.1

H! friend, In this post I would let you know how we can create and deploy WCF service at Windows Azure Cloud and Use it in Windows 8.1 Windows Store Application.

Pre-requisites :-

1. Visual Studio 2013

2. Windows 8.1 installed on working system.

3. Windows Azure Account if you don’t have then go to there official webiste  azure website.

4. Windows Azure SDK for windows download azure sdk

Step1 :- Creat a WCF Service for Azure Cloud

Open Visual Studio 2013 and click on “File” -> “New Project” and it will open dialogue like below. Then select “Cloud” ->  “Windows Azure Cloud Service” like below image.

create cloud service

Step 2:- Add Serive Web Role

When you click “OK”, it will show a dialogue again. Follow the three steps given in below image.

Add Service Web Role

Rename the Service Role by right click on “WCF Service Web Role” and name it what ever you want. Your solution explorer will looks like below image.

Solution Explorer After adding WCF Service

Rename the Service1 class and IService1 interface using refactor menu rename command like below. I have just rename these two files like AtlasCloudService and IAtlasCloudService.

Solution Explorer After adding WCF Service

Step 3 :- Create Function in WCF

First create the function in the IAtlasService.cs interface class and data members also FirstName, LastName etc like below image.

define function in Interface class

Create Function in AtlasService.svc.cs Class like below image.

define function in svc class

Step 4 :- Build and Deploy the Azure Cloud Server

Right click on the “Atlas Cloud Service” and Select “Package”. It will open dialogue box like below image.

Package dialog

Click on package will create two files in your project bin\release\app.publish folder one will be package and other will be configuration file.

Step 5 :- Deploy to Windows Azure Cloud

Login to your windows azure account and then click on the “Cloud Service”, it will show a “New +” button at the left bottom corner, When you click on it will show dialog box like below image.

cloud service

Click on the “Quick Create” and then URL Give the name whatever you want you can give  and Select Region. After that click on the  “Create Cloud Service”. It will show like below image.

added service

Click on the “Name” it will show you “Upload a New Production Deploment” under “Deployment Setting”. When you click on that link, it will open a dialog box. Put the “Deployment Label” and Package and Configuration files we have build in Step 4.

You have to hit tick arrow from the bottom right corner to deploy web service, it will take few minutes.

After successfully deployment it will show message like below :-

Sucessfully added service

Now I can browse my service like below image.

access webservice

Step 6 :- Use Windows Azure WCF in windows 8.1 Application

We can use windows azure service in windows 8.1 app very easily, first of all you have to create a windows store application in visual studio 2013 like below image.

windows store app

Right Click on the Solution Explorer and Click on “Add” then “Add Service Reference”.

It will open a dialogue box like below image.

Add Service to windows 8.1

Give the Namespace to your service, it will help to access the service functions.

Add a button on the MainPage.xaml, and on click event add the code in the MainPage.xaml.cs file like below image.

access service funtion code example

I have added greetingOutput name textblock that will show returned data by service like below image.

output windows

Hope it helps to create and deploy wcf service at azure and access it in windows 8.1 application.

Happy Coding….

Posted by | View Post | View Group