How To Create And Use Azure Cosmos DB In Xamarin.Forms Application For Android

Azure Cosmos DB is a globally distributed, multi-model database service, it supports document, key-value, wide-column, and graph databases by using popular APIs and programming models. More Details https://docs.microsoft.com/en-us/azure/cosmos-db/introduction.

Reading this article, you can learn how to create and use Azure Cosmos DB In Xamarin Forms application using Android with XAML and Visual C# in cross-platform application development.

The following important tools are required for developing UWP,

  1. Microsoft Azure Subscription (https://azure.microsoft.com ) or You can Try Azure Cosmos DB for free without an Azure subscription, free of charge and commitments.
  2. Windows 10 (Recommended)
  3. Visual Studio 2017 Community (https://www.visualstudio.com/downloads/ )

Now, we can discuss step by step App development.

Step 1

Log in to your Microsoft Azure Subscription Account in https://azure.microsoft.com (Free Trial also there). Or you can Try Azure Cosmos DB for free without an Azure subscription, free of charge and commitments. In this article, we discussed with Microsoft Azure subscription.

Step 2

After logging in your Azure portal, click create a resource and search the Azure Cosmo DB,

 

Click the Create button for creating Cosmos DB Account,

 

Type the ID, select SQL as API with different options( SQL, Mongo DB, Cassandra, Azure Table, Gremlin(graph) and select the Resource group and Location.

 

After creating your Cosmos DB account, open the resource and select QuickStart,

 

Select the platform as Xamarin and click on Create Items Collection Button. This will create a ToDoList Collection in the database.

 

Now, you can download your Xamarin Sample Application.

 

While clicking the Document Explorer, we can view the empty ToDoList with Item documents,

 

Step 3

Now, we can extract and open the downloaded app zip file from Azure Portal, 

 
It includes 3 projects (iOS, Android, Shared),
 

Enable the deploy option in Configuration manager for Android Project,

 

Step 4

Build and Run the project in Android emulator, the collection Document update in Azure Portal,

 

Adding new data to Android Emulator,

 

After inserting the value the new document is added to it,

 
We can add one more data, 
 
 

Summary

Now, you have successfully tested Azure Cosmos DB In Xamarin.Forms application with Android using Visual C# and Xamarin.

G
M
T
 
Text-to-speech function is limited to 200 characters


Similar Articles