Azure App Service: Mobile Apps

Build and scale mobile backends with ease.

Getting Started with Azure Mobile Apps

Azure Mobile Apps is a service that provides a backend for your iOS, Android, and Windows mobile applications. It offers features like data synchronization, authentication, push notifications, and offline capabilities.

Key Features

Creating Your First Mobile App Backend

Follow these steps to set up a basic Mobile App backend:

  1. Create a Mobile App Service: In the Azure portal, search for "Mobile App" and create a new resource. Configure the app name, subscription, resource group, and platform (iOS, Android, Windows, or None).
  2. Configure Data: Choose a data source (e.g., Azure SQL Database) and configure the connection string. You can also create tables directly within the Mobile App service.
  3. Add SDKs to Your App: Integrate the Azure Mobile Apps SDK into your mobile application project. The SDKs provide client-side libraries for interacting with your backend.

Example: Fetching Data

Here's a simplified example of how you might fetch data from your Mobile App backend using the JavaScript SDK:

                
// Initialize the MobileServiceClient
var client = new WindowsAzure.MobileServiceClient(
    "YOUR_APP_URL",
    "YOUR_APP_KEY");

// Get a reference to the TodoItem table
var todoItemTable = client.getTable('TodoItem');

// Query all TodoItems
function refreshTodoItems() {
    todoItemTable.read()
        .done(function (results) {
            var output = [];
            results.forEach(function (item) {
                output.push(JSON.stringify(item));
            });
            document.getElementById('todoItems').innerText = output.join('\n');
        }, function (error) {
            console.error("Error loading items: " + error);
        });
}

// Call refreshTodoItems to load data
refreshTodoItems();
                
            

Authentication Flow

Mobile Apps supports various authentication providers. The typical flow involves redirecting the user to the provider's login page and then handling the response.

                
// Authenticate with Google
client.login('google', {
    // Optional: scopes or other provider-specific parameters
}).done(function(user) {
    console.log('Logged in as: ' + user.userId);
}, function(error) {
    console.error('Authentication failed: ' + error);
});
                
            
Important: Ensure your application's redirect URIs are correctly configured in the identity provider's settings and in your Azure Mobile App service.

Offline Sync Configuration

To enable offline sync, you need to configure your tables with the appropriate settings and implement the sync logic in your client application.

Tip: For complex conflict resolution, consider implementing custom logic that handles merging changes based on specific business rules.

Further Reading