Azure Tools

Getting Started local development with Azure Cosmos DB services – Part 2

May 29, 2017 .NET, .NET Core 1.0, .NET Core 1.0.1, .NET Framework, ASP.NET, Azure, Azure SDK Tools, Azure Tools, Cloud Computing, CodeSnippets, CosmosDB, Document DB, Microsoft, PaaS, SaaS, Visual Studio 2015, Visual Studio 2015 Update 3, Visual Studio 2017, VisualStudio, VS2015, VS2017, Windows, Windows 10, Windows Azure Development, Windowz Azure No comments

In my previous article we discussed about setting local development environment using Cosmos DB Emulator for Windows. With this part 2 of the article, we will cover developing, debugging and integration related aspects of using Cosmos DB Emulator.

Developing with Cosmos DB Emulator

Once you have Cosmos DB emulator installed and running on your machine, you can use any supported Cosmos DB SDK or Cosmos DB REST API to interact with emulator. This process is same as you are using a Cosmos DB cloud service.

Cosmos DB Emulator also provides a build-in visual explorer through which you can view,create and edit collections and documents.

image

Before you integrate Cosmos DB SDK or Cosmos DB REST API you would need to generate master key for authentication. Unlike cloud service, Cosmos DB emulator only support single fixed account and master key.  You would not be able to communicate with Emulator without this master key.

Default Master Key:

Account name: localhost:<port>

Account key: C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==

PS: This key is only to be used in Emulator. You cannot use the same key for Production(Cosmos DB Cloud Service).

Furthermore, if you want to set your own key. You can go to command line references and run DocumentDB.Emulator.exe with sufficient command switch to set your own key. Remember it should meet the key security requirements. See command-line tool reference for more information.

The Azure Cosmos DB Emulator is installed by default to the C:\Program Files\Azure Cosmos DB Emulator  or C:\Program Files\DocumentDB Emulator  directory.

Once you have account name and key, you are good to go with development and debugging using Azure Cosmos DB emulator.

Let us start looking at how to use CosmosDB SDK. Once you add Cosmos DB SDK for .NET from NUGET sources. You would need to import the following namespaces to reference necessary classes.

 using Microsoft.Azure.Documents;
   
 using Microsoft.Azure.Documents.Client;
   
 using Microsoft.Azure.Documents.Linq;

Simple code to establish connection:

// Connect to the Azure Cosmos DB Emulator running locally use DocumentClient class in : 
DocumentClient client = new DocumentClient(
    new Uri("https://localhost:8081"), 
    "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==");

In the above code block we are directly embedding endpoint, key in the source code.But as a suggested approch keeping in mind to easily point to production service would be maintain the key in Web.config appSettings.

   <add value="https://localhost:8081/" key="endpoint"/>
    <add value="C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==" key="authKey"/>
 

Add NuGet reference to Microsoft.Azure.DocumentDB  (always use the latest version of the library)

image

For the ease of this article, I am going to use the existing ToDoList sample from DocumentDB Samples provided by Microsoft. You can originally find the same source from C:\Program Files\DocumentDB Emulator\Packages\DataExplorer\quickstart.

image

Copy and Unzip DocumentDB-Quickstart-DotNet.zip and open todo.sln in Visual Studio 2017 and your solution structure will look like below:

image

Now run the application in your Visual Studio.

1. You will see an initial screen:

image

2. Click on Create New:

image

3. New record will be added to your Azure Cosmos DB Emulator:

image

4. To verify in Cosmos DB emulator now open Cosmos DB explorer, click on Collections and Select ToDoList

image

5.Expand Documents and select item with id:da305da3-c1dc-4e34-94d9-fd7f82d26c58

image

Hope this article was helpful for you with initial development.  Share your feedback through comments and share this to your friends and colleagues.

Useful Links:

Getting Started local development with Azure Cosmos DB services – Part 1

May 20, 2017 .NET, Azure, Azure SDK, Azure SDK Tools, Azure Tools, Cloud Computing, Computing, CosmosDB, Data Services, Document DB, Emerging Technologies, KnowledgeBase, Microsoft, PaaS, Visual Studio 2013, Visual Studio 2015, Visual Studio 2017, VS2013, VS2015, VS2017, Windows 10, Windows Azure Development, Windows Server 2012 R2, Windows Server 2016, Windowz Azure 1 comment , ,

Azure Cosmos DB is a multi-API, multi-model highly scalable NoSQL database services from Microsoft Azure platform. In order to develop an application consuming Azure Cosmos DB requires an azure live subscription or emulator in your local machine.

The Azure Cosmos DB Emulator provides a local development/test environment for Azure Cosmos DB development purposes. Using Azure Cosmos DB Emulator, you can develop and test your application locally, without needing an azure subscription or without subscription costs.

With this article I am going to take you through necessary steps and requirements to set up your local environment.

1. Pre-Requisites:

Azure Cosmos DB emulator has the following software and hardware requirements:

  • Software requirements
    • Windows Server 2012 R2, Windows Server 2016, or Windows 10
  • Minimum Hardware requirements
    • 2 GB RAM
    • 10 GB available hard disk space

2. Installation:

  • Download Azure Cosmos DB Emulator   (DocumentDb.Install.msi)   ** do not get confused by the name. Azure Cosmos DB is a super set of Document DB, and the DocumentDb emulator they tweaked a bit to support Cosmos Db.
  • Install DocumentDb.Install.msi

Additionally Azure CosmosDB emulator can be run on Docker for Windows. After installing Docker for Windows, you can pull the Emulator image from Docker Hub.

docker pull microsoft/azure-documentdb-emulator

imageimageimage

3. Start/Launch Azure Cosmos DB Emulator:

image image

After some time you can see the emulator started. When the Azure Cosmos DB emulator launches it will automatically open the Azure Cosmos DB Data Explorer in your browser.

The address will appear as https://localhost:8081/_explorer/index.html

Incase you have closed browser and later would like to open the explorer again, you can open the Data Explorer by right clicking on the taskbar menu.

image

image

Now you can write some sample app to try it, or download already created sample applications from Microsoft depending on the preferred platform of your choice.

4. Limitation of Azure Cosmos DB Emulator: (or Differences between Azure Cosmos DB Emulator vs Real Cosmos DB Cloud Service)

Since the Azure Cosmos DB Emulator provides an emulated environment running on a local developer workstation, there are some fundamental differences between the emulator and an Azure Cosmos DB account in the cloud:

The following table is also helpful in determining when to use Cosmos DB Emulator and when direct cloud service. Depending on the choice of requirement, you would need to use associated services efficiently.


Cosmos DB Emulator Cosmos DB Cloud Service
Supports only a single fixed account and a well-known master key. Key regeneration is not possible. Supports multiple accounts and different master keys. You can regenerate keys any time from Azure Portal.
Non scalable Highly scalable
Does not support larger data sets Support for large data sets
Does not simulate consistency levels Different Consistency levels available
Does not simulate multi-region replication Configurable as part of the platform, as needed basis.
Does not support quota override feature Supports document size limit increases, increased partitioned collection storage etc.
Might not support most recent changes to Cosmos Db platform Most recent platform update will be available.

Hope this article was helpful for your initial start. If you would need to understand further on Azure Cosmos DB development follow the links. I will be writing further insights in later sessions.

Visual Studio 2017 Released

March 7, 2017 .NET, .NET Core 1.0, .NET Core 1.0.1, .NET Framework, .NET Framework 4.6, ASP.NET, ASP.NET 4.5, ASP.NET AJAX, ASP.NET Core 1.0, ASP.NET Core 1.0.1, Azure Tools, C#.NET, KnowledgeBase, Microsoft, SignalR, Visual Studio 2017, VisualStudio, VS2017, Web API, Web API v2.0, Windows, Windows 10 No comments

Microsoft has released today the latest version of Visual Studio.

The new Visual Studio 2017 will help you develop apps for  Android, iOS, Windows, Web, and Cloud.  It will also help you use version management, be agile, and collaborate effectively.

Includes support for Xcode 8.3, iOS 10.3, watchOS 3.2, and tvOS 10.2 tools and APIs in the Xamarin.VS Extension for Visual Studio 2017..

To know more about all the features included, please go through What’s New in Visual Studio 2017 

RTM VERSION 15.0
RTM BUILD 26228.04
RELEASE DATE 03/07/2017
RELEASE NOTES Release Notes

Download:

New Certification – MCSD – Azure Solution Architect

May 25, 2015 .NET, .NET Framework, AppFabric, Azure, Azure Tools, Certification, Cloud Services, KnowledgeBase, MCSD, Microsoft, SQL Azure, Visual Studio 2013, VisualStudio, VS2013, Windows Azure Development, Windowz Azure No comments

Microsoft has made availability of new MCSD certification called as “MCSD – Azure Solutions Architect“.

Required Exams:
070-532: Developing Microsoft Azure Solutions
070-533: Implementing Microsoft Azure Infrastructure Solutions
070-534: Architecting Microsoft Azure Solutions

Once you complete the above required exams you will be awarded MCSD – Azure Solutions Architect certificate valid for 2 years.

PS: You will have to retake the renewal exam every two years to stay on as an MSDN Azure Solutions Architect.

For more details on the certification: https://www.microsoft.com/learning/en-us/mcsd-azure-architect-certification.aspx 

Get – Visual Studio 2013 – Update 4

November 12, 2014 .NET, .NET Framework, .NET Framework 4.5.2, ASP.NET, ASP.NET 4.5, ASP.NET AJAX, ASP.NET MVC, Azure, Azure Tools, C#.NET, Microsoft, SignalR, SQL Azure, Updates, Visual Studio 2013, VisualStudio, VS2013, WCF, WCF Data Services, Web API, Windowz Azure No comments

Microsoft has released an update for Visual Studio 2013, this update is the latest in a cumulative series of feature additions and bug fixes for Visual Studio 2013.

Download VS2013.04.exe  (Online/Web Install)

Download VS2013.04.iso (Offline Install)

For more information,

For more information:

Also see Visual Studio Updates and the Visual Studio Update KB Article.

Watch Channel 9 Series on VS 2013 Update 4

Windows Azure SDK for .NET–Version 2.0 (for Visual Studio 2010 SP1/2012)

April 30, 2013 .NET, .NET Framework, AppFabric, Azure, Azure SDK, Azure Tools, Cloud Computing, Cloud Services, KnowledgeBase, Media Services, Microsoft, Microsoft SDKs, Mobile Services, SQL Azure, VisualStudio, VS2010, VS2012, Windows, Windows Azure, Windows Azure Development, Windows Azure Training Kit, Windowz Azure No comments

Latest version of Windows Azure SDK for .NET – Version 2.0 released by Microsoft.

DOWNLOAD: Windows Azure SDK for .NET 2.0 (Offline Installer)

Recommended: Instead of manually downloading the files from above link, it is recommended you use the automated one-click install provided by the Web Platform Installer x64 or x86.

Click on the appropriate install link below based on your version of Visual Studio:

DOWNLOAD:  Windows Azure Training Kit – April 2013