This book shows you how to develop applications that work with Azure Cosmos DB. Azure and other cloud applications typically work with massive amounts of data that can be organized in different ways. These applications will often require elastic scalability of storage and throughput, and will often need to work across new geographical regions. This is the problem that Microsoft's Azure Cosmos DB service addresses. It is a globally distributed, massively scalable, and multi-model NoSQL database service.
You will learn how to use the Azure Cosmos DB Emulator. You will start by writing simple queries against Cosmos DB data and handling the responses, and then learn how to use more sophisticated querying constructs. You will create a full C# application that integrates with Cosmos DB, and learn about the .NET Core 2 classes that are needed to do so. You will work with LINQ and POCOs to cement your querying capabilities.
Having mastered Cosmos DB's NoSQL capabilities by the end of this book, you will be able to build scalable, globally distributed, and highly responsive applications.
This book is for C# developers. You do not require any knowledge of Azure Cosmos DB, but familiarity with the Azure platform would be an advantage.
Chapter 1, Introduction to NoSQL in Cosmos DB, introduces you to the features of Cosmos DB and the NoSQL data model. You will also learn about the different elements of the Cosmos DB resource model, which will allow you to have a clear understanding of how to work with this database service.
Chapter 2, Getting Started with Cosmos DB Development and NoSQL Document Databases, will teach you how to provision a Cosmos DB account that uses the SQL API, and you will start working with a document database, along with its collections and documents. You will use the web-based Azure portal and work with Azure Cosmos DB Explorer.
Chapter 3, Writing and Running Queries on NoSQL Document Databases, will have you writing and running queries to retrieve data from the documents in a collection. You will learn how to use the Cosmos DB dialect of SQL to work against a document database with the SQL API. Most importantly, you will understand the different ways of working with documents, their sub-documents, and their arrays, and you will learn about how queries consume resource units.
Chapter 4, Building an Application with C#, Cosmos DB, a NoSQL Document Database, and the SQL API, will get you using Cosmos DB, the .NET Core SDK, the SQL API, and C# to code our first Cosmos DB application. The main focus will be on learning about many important aspects related to the SDK, as well as how to easily build a first version of the application we'll be working with.
Chapter 5, Working with POCOs, LINQ, and a NoSQL Document Database, will keep you working with the .NET Core SDK, but this time, you will work with POCOs and LINQ queries. You will take advantage of the strongly typed features of C# and the functional programming features that LINQ provides for working with Cosmos DB.
Chapter 6, Tuning and Managing Scalability with Cosmos DB, explores aspects that will enable you to design and maintain scalable architectures with Cosmos DB. You will use the sample application you will have built to understand complex topics related to scalability.
You will need a Microsoft Azure account in order to use Cosmos DB. You should also be familiar with the Azure platform to get the most out of this book.
You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.com/support and register to have the files emailed directly to you.
You can download the code files by following these steps:
- Log in or register at www.packt.com.
- Select the
SUPPORT
tab. - Click on
Code Downloads & Errata
. - Enter the name of the book in the
Search
box and follow the onscreen instructions.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
- WinRAR/7-Zip for Windows
- Zipeg/iZip/UnRarX for Mac
- 7-Zip/PeaZip for Linux
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Guide-to-NoSQL-with-Azure-Cosmos-DB. In case there's an update to the code, it will be updated on the existing GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://www.packtpub.com/sites/default/files/downloads/9781789612899_ColorImages.pdf.
There are a number of text conventions used throughout this book.
CodeInText
: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Right-click on the Documents
element for the VideoGames1
collection."
A block of code is set as follows:
SELECT * FROM Videogames v WHERE v.id = '2'
Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Click Create a resource | Databases | Azure Cosmos DB
."
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at [email protected]
.
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packt.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.
Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected]
with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packt.com.
Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!
For more information about Packt, please visit packt.com.