This product is retired. For a replacement for projects using .NET 8 or later, see the Community Toolkit Datasync library.
This tutorial shows you how to add a cloud-based backend service to an Android mobile app by using Xamarin and an Azure mobile app backend. You create both a new mobile app backend and a simple Todo list app that stores app data in Azure.
You must complete this tutorial before other Xamarin Android tutorials about using the Mobile Apps feature in Azure App Service.
To complete this tutorial, you need:
C:\Temp> Expand-Archive azure-mobile-apps-main.zip
The samples are located in the samples folder within the extracted files. The sample for the quick start is named TodoApp . You can open the sample in Visual Studio by double-clicking the TodoApp.sln file.
If you have already deployed the backend from another quick start, you can use the same backend and skip this step.
To deploy the backend service, we will:
The TodoApp sample is configured to support the Azure Developer CLI. To complete all steps (provisioning and deploying):
If you aren't already signed-in to Azure, the browser launches to ask you to sign-in. You're then be prompted for a subscription and Azure region to use. The Azure Developer CLI then provisions the necessary resources and deploys the service code to the Azure region and subscription of your choice. Finally, the Azure Developer CLI writes an appropriate Constants.cs file for you.
You can run the azd env get-values command to see the SQL authentication information should you wish to access the database directly.
If you have completed the steps with the Azure Developer CLI, proceed to the next step. If you don't wish to use the Azure Developer CLI, proceed with the manual steps.
az group create -l westus -g quickstart
az deployment group create -g quickstart --template-file azuredeploy.json --parameters sqlPassword=MyPassword1234
az deployment group show -g quickstart -n azuredeploy --query properties.outputs
An example output is:
Open the TodoApp.sln in Visual Studio.
Your client application needs to know the base URL of your backend so that it can communicate with it.
If you used azd up to provision and deploy the service, the Constants.cs file was created for you and you can skip this step.
namespace TodoApp.Data < public static class Constants < /// /// The base URI for the Datasync service. /// public static string ServiceUri = "https://demo-datasync-quickstart.azurewebsites.net"; > >
Once complete, close the Android Device Manager.
Start your Android emulator before continuing. You can do this by opening the Android Device Manager and pressing Start next to your chosen emulator.
Once the app has started, you see an empty list and a floating action button to add items in the emulator. You can: