All Projects → Azure-Samples → documentdb-dotnet-todo-app

Azure-Samples / documentdb-dotnet-todo-app

Licence: MIT license
This sample shows you how to use the Microsoft Azure DocumentDB service to store and access data from a ASP.NET MVC application hosted on Azure Websites.

Programming Languages

javascript
184084 projects - #8 most used programming language
C#
18002 projects
HTML
75241 projects
CSS
56736 projects
ASP.NET
160 projects
page_type languages products description
sample
csharp
azure
dotnet
aspnet
azure-cosmos-db
This sample shows you how to use the Microsoft Azure Cosmos DB service to store and access data from an ASP.NET MVC application.

This repository has been archived. It uses the Azure Cosmos DB .NET SDK Version 2 which we have recently announced will be deprecated in August 2024. An updated version of this sample using the Azure Cosmos DB .NET SDK Version 3 can be found here.

Web application development with ASP.NET MVC using Azure Cosmos DB

This sample shows you how to use the Microsoft Azure Cosmos DB service to store and access data from an ASP.NET MVC application hosted on Azure Websites.

For a complete end-to-end walk-through of creating this application, please refer to the full tutorial on the Azure Cosmos DB documentation page.

Running this sample

  1. Before you can run this sample, you must have the following prerequisites:

2.Clone this repository using Git for Windows (http://www.git-scm.com/), or download the zip file.

3.From Visual Studio, open the todo.sln file from the root directory.

4.In Visual Studio Build menu, select Build Solution (or Press F6).

5.Retrieve the URI and PRIMARY KEY (or SECONDARY KEY) values from the Keys blade of your Azure Cosmos DB account in the Azure portal. For more information on obtaining endpoint & keys for your Azure Cosmos DB account refer to View, copy, and regenerate access keys and passwords.

If you don't have an account, see Create a database account to set one up.

6.In the Web.config file, located in the project root, find endpoint and authKey and replace the placeholder values with the values obtained for your account.

<add key="endpoint" value="~enter URI for your Azure Cosmos DB Account, from the Azure portal~" /> 
<add key="authKey" value="~enter either Primary or Secondary key for your Azure Cosmos DB Account, from the Azure portal~" /> 

7.You can now run and debug the application locally by pressing F5 in Visual Studio.

Deploy this sample to Azure

  1. In Visual Studio Solution Explorer, right-click on the project name and select Publish...

  2. Using the Publish Website dialog, select Microsoft Azure Web Apps

  3. In the next dialog, either select an existing web app, or follow the prompts to create a new web application. Note: If you choose to create a web application, the Web App Name chosen must be globally unique.

  4. Once you have selected the web app, click Publish

  5. After a short time, Visual Studio will complete the deployment and open a browser with your deployed application.

For additional ways to deploy this web application to Azure, please refer to the Deploy a web app in Azure App Service article which includes information on using Azure Resource Manager (ARM) Templates, Git, MsBuild, PowerShell, Web Deploy, and many more.

About the code

The code included in this sample is intended to get you going with a simple ASP.NET MVC application that connects to Azure Cosmos DB. It is not intended to be a set of best practices on how to build scalable enterprise grade web applications. This is beyond the scope of this quick start sample.

More information

ocument

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].