Creating a Microsoft Azure Mobile Service in Visual Studio 2015

In this post, we will create a basic Microsoft Azure Mobile Service using Visual Studio 2015 IDE. By using Visual Studio IDE, we can easily create an Azure Mobile service on localhost.

For creating a Mobile Service using VS IDE, we would create a new project in Visual Studio as follows:

Go to File -> New Project -> Installed Templates -> Visual C# -> Cloud -> Azure Mobile Service


Now, if you have an Azure account, you have to login and add details for the Service. The detail page would look like:

azure1Now, after adding details our project will be created and it will take some time to prepare the application for the use. As our application is created, we will delete the sample ToDoItem class along with it’s controller from the solution, and we will add our user defined class. Here, in our solution, we are adding a class Book to the solution:


Now, we will add code for the Controller for Book class, which is as follows:


Now, we have our Book Class and BookController Class which in the solution.  We will now open MobileServiceContext.cs file, where we will add DbSet of our class “Book”:

After adding code in the MobileServiceContext.cs file, we will open WebConfig.cs file where we will make some changes in the code which was actually set for our ToDoItem class object and it’s controller to our Book class and it’s controller. The changes to be made are in the code below:

In the above code, we are actually adding some data to our Book class list which can be sent via response when a person calls the GET method of the service. This is only the demo data, you can push your own data and pull that data from the api using GET method.

Now, we will publish the application on to the Azure server to save local changes in the application to the Azure server. Just follow the steps to publish the data and click on Publish. 

After publishing data, we can check our published service by using GET method of the Mobile service on a Web Browser (you can use Fiddler too for checking GET method of Azure Mobile Services Api). When I run my api to GET data in json, it shows data like below:

azure2Now, you can also create your Azure mobile services locally on Visual Studio and publish it later on to Azure Server. For parsing the json string from Api to your Universal Windows Application check the following blog post: