Book Image

Guide to NoSQL with Azure Cosmos DB

By : Gaston C. Hillar, Daron Yöndem
Book Image

Guide to NoSQL with Azure Cosmos DB

By: Gaston C. Hillar, Daron Yöndem

Overview of this book

Cosmos DB is a NoSQL database service included in Azure that is continuously adding new features and has quickly become one of the most innovative services found in Azure, targeting mission-critical applications at a global scale. This book starts off by showing you the main features of Cosmos DB, their supported NoSQL data models and the foundations of its scalable and distributed architecture. You will learn to work with the latest available tools that simplify your tasks with Cosmos DB and reduce development costs, such as the Data Explorer in the Azure portal, Microsoft Azure Storage Explorer, and the Cosmos DB Emulator. Next, move on to working with databases and document collections. We will use the tools to run schema agnostic queries against collections with the Cosmos DB SQL dialect and understand their results. Then, we will create a first version of an application that uses the latest .NET Core SDK to interact with Cosmos DB. Next, we will create a second version of the application that will take advantage of important features that the combination of C# and the .NET Core SDK provides, such as POCOs and LINQ queries. By the end of the book, you will be able to build an application that works with a Cosmos DB NoSQL document database with C#, the .NET Core SDK, LINQ, and JSON.
Table of Contents (13 chapters)
Title Page
Packt Upsell
Contributors
Preface
Index

Creating a .NET Core 2 application to interact with Cosmos DB


Now we will create a new multiplatform .NET Core 2 console app. We will install the necessary NuGet packages to work with the Cosmos DB SDK and make it easy to use a JSON configuration file for our application.

In Visual Studio, select File | New | Project and select Visual C# | .NET Core | Console App (.NET Core). Enter SampleApp1 for the project name. The code file for the sample is included in the learning_cosmos_db_04_01 folder in the dot_net_core_2_samples/SampleApp1/SampleApp1.sln file.

Install the NuGet packages and versions detailed in the next table. If there are newer versions available, you will have to verify the change log to make sure that there are no breaking changes. The sample has been tested with the specified versions:

Package name

Version

Microsoft.Azure.DocumentDB.Core

2.0.0

Microsoft.Extensions.Configuration

2.1.1

Microsoft.Extensions.Configuration.Json

2.1.1

 

As previously explained, the Microsoft.Azure.DocumentDB...