Windows Azure: Create Your First Mobile Service C#

Overview

banner1

This article explains how to create our first Mobile Service C# on Windows Azure. We hope by reading this tutorial you will be able to create your first Mobile services.

Mobile Services

Mobile Services allow you to accelerate your mobile app development by providing a turnkey way to structure storage, authenticate users and send push notifications. With SDKs for Windows, Android, iOS and HTML as well as a powerful and flexible REST API, Mobile Services lets you to build connected applications for any platform and deliver a consistent experience across devices.

Let's Start!

PART 1

Let's use the following procedure to create Mobile Services.

Step 1

Create a new mobile service.

CreateMobileService

Step 2

Provide the URL of your Mobile Service.

Url4MobileService

Step 3
 
Create a new databse.

newDatabase

wait

Good! Now your mobile service is ready.

Ready

Step 4

Create a new table, technologies.

NewTable

technologies

PART 2

Now use the following procedure to use this service in your mobile application.

Step 1

  • Open Visual Studio 2013
  • Select Visual C# -> Windows Store
  • Select Blank App (XAML)
     
  • Name this application something like MobileService2014
     
  • Click on OK

    BlankApp

Step 2

Add a reference of the Windows Azure Mobile Services Managed Client to the project.

SolnExplorer
 
Step 3

You need the key and application URL to work with Windows Azure Mobile Services. 

URL

Step 4

Now add the following namespaces in MainPage.xaml.cs. 

  1. using Windows.UI.xaml.Navigation;  
  2.   
  3. using Microsoft.WindowsAzure.MobileServices;  
  4.   
  5. using System.Runtime.Serialization;  

Step 5

Create an entity class as in the following:

technologiesClass

Step 6

Create global variables and an instance as in the following:

GlobalVariables

Step 7

Insert this XAML code (design): 

  1. <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}" >  
  2.           
  3. <Grid.RowDefinitions>  
  4.               
  5. <RowDefinition Height="100″ />  
  6.               
  7. <RowDefinition Height="100″ />  
  8.               
  9. <RowDefinition Height="100″ />             
  10.           
  11. </Grid.RowDefinitions>  
  12.           
  13. <StackPanel Grid.Row="0″ Orientation="Horizontal" Margin="40,40,0,0″>  
  14.               
  15. <TextBlock Text="Name" FontSize="40″ />  
  16.             <TextBox x:Name="txtName" VerticalAlignment="Top" Width="400″ />  
  17.         </StackPanel>  
  18.         <StackPanel Orientation="Horizontal" Grid.Row="1″ Margin="40,40,0,0″>  
  19.             <TextBlock Text="Technology" FontSize="40″ />  
  20.             <TextBox x:Name="txtTechnology" VerticalAlignment="Top" Width="400″ />  
  21.         </StackPanel>  
  22.         
  23.             <Button Grid.Row="2″ x:Name="btnInsert" Click="btnInsert_Click_1″ Content="Insert Record" Height="72″Width="233″ Margin="248,42,0,-14″ />  
  24.          
  25.  </Grid>   
DesignView

 

Step 8

Now write the following code to the btnInsert_Click event:

InsertCode 
 
Congratulation! You can now verify your service.  

Congrats

Summary

In this article we learned how to create and use a mobile service in Windows Azure.

Up Next
    Ebook Download
    View all
    Learn
    View all