Overview
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.
Step 2
Provide the URL of your Mobile Service.
Step 3
Create a new databse.
Good! Now your mobile service is ready.
Step 4
Create a new table, 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
Step 2
Add a reference of the Windows Azure Mobile Services Managed Client to the project.
Step 3
You need the key and application URL to work with Windows Azure Mobile Services.
Step 4
Now add the following namespaces in MainPage.xaml.cs.
- using Windows.UI.xaml.Navigation;
-
- using Microsoft.WindowsAzure.MobileServices;
-
- using System.Runtime.Serialization;
Step 5
Create an entity class as in the following:
Step 6
Create global variables and an instance as in the following:
Step 7
Insert this XAML code (design):
- <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}" >
-
- <Grid.RowDefinitions>
-
- <RowDefinition Height="100″ />
-
- <RowDefinition Height="100″ />
-
- <RowDefinition Height="100″ />
-
- </Grid.RowDefinitions>
-
- <StackPanel Grid.Row="0″ Orientation="Horizontal" Margin="40,40,0,0″>
-
- <TextBlock Text="Name" FontSize="40″ />
- <TextBox x:Name="txtName" VerticalAlignment="Top" Width="400″ />
- </StackPanel>
- <StackPanel Orientation="Horizontal" Grid.Row="1″ Margin="40,40,0,0″>
- <TextBlock Text="Technology" FontSize="40″ />
- <TextBox x:Name="txtTechnology" VerticalAlignment="Top" Width="400″ />
- </StackPanel>
-
- <Button Grid.Row="2″ x:Name="btnInsert" Click="btnInsert_Click_1″ Content="Insert Record" Height="72″Width="233″ Margin="248,42,0,-14″ />
-
- </Grid>
Step 8
Now write the following code to the btnInsert_Click event:
Congratulation! You can now verify your service.
Summary
In this article we learned how to create and use a mobile service in Windows Azure.