Skip to content

Latest commit

 

History

History
141 lines (110 loc) · 11.6 KB

documentdb-create-documentdb-website.md

File metadata and controls

141 lines (110 loc) · 11.6 KB
title description services author manager editor documentationcenter ms.assetid ms.service ms.workload ms.tgt_pltfrm ms.devlang ms.topic ms.date ms.author
Deploy DocumentDB and Azure App Service Web Apps using an Azure Resource Manager Template | Microsoft Docs
Learn how to deploy a DocumentDB account, Azure App Service Web Apps, and a sample web application using an Azure Resource Manager template.
documentdb, app-service\web
h0n
jhubbard
monicar
087d8786-1155-42c7-924b-0eaba5a8b3e0
documentdb
data-services
na
na
article
08/02/2016
hawong

Deploy DocumentDB and Azure App Service Web Apps using an Azure Resource Manager Template

This tutorial shows you how to use an Azure Resource Manager template to deploy and integrate Microsoft Azure DocumentDB, an Azure App Service web app, and a sample web application.

Using Azure Resource Manager templates, you can easily automate the deployment and configuration of your Azure resources. This tutorial shows how to deploy a web application and automatically configure DocumentDB account connection information.

After completing this tutorial, you will be able to answer the following questions:

  • How can I use an Azure Resource Manager template to deploy and integrate a DocumentDB account and a web app in Azure App Service?
  • How can I use an Azure Resource Manager template to deploy and integrate a DocumentDB account, a web app in App Service Web Apps, and a Webdeploy application?

Prerequisites

Tip

While this tutorial does not assume prior experience with Azure Resource Manager templates or JSON, should you wish to modify the referenced templates or deployment options, then knowledge of each of these areas will be required.

Before following the instructions in this tutorial, ensure that you have the following:

Step 1: Download the template files

Let's start by downloading the template files we will use in this tutorial.

  1. Download the Create a DocumentDB account, Web Apps, and deploy a demo application sample template to a local folder (e.g. C:\DocumentDBTemplates). This template will deploy a DocumentDB account, an App Service web app, and a web application. It will also automatically configure the web application to connect to the DocumentDB account.
  2. Download the Create a DocumentDB account and Web Apps sample template to a local folder (e.g. C:\DocumentDBTemplates). This template will deploy a DocumentDB account, an App Service web app, and will modify the site's application settings to easily surface DocumentDB connection information, but does not include a web application.

Step 2: Deploy the DocumentDB account, App Service web app and demo application sample

Now let's deploy our first template.

Tip

The template does not validate that the web app name and DocumentDB account name entered below are a) valid and b) available. It is highly recommended that you verify the availability of the names you plan to supply prior to submitting the deployment.

  1. Login to the Azure Portal, click New and search for "Template deployment". Screenshot of the template deployment UI

  2. Select the Template deployment item and click Create Screenshot of the template deployment UI

  3. Click Edit template, paste the contents of the DocDBWebsiteTodo.json template file, and click Save. Screenshot of the template deployment UI

  4. Click Edit parameters, provide values for each of the mandatory parameters, and click OK. The parameters are as follows:

    1. SITENAME: Specifies the App Service web app name and is used to construct the URL that you will use to access the web app (e.g. if you specify "mydemodocdbwebapp", then the URL by which you will access the web app will be mydemodocdbwebapp.azurewebsites.net).

    2. HOSTINGPLANNAME: Specifies the name of App Service hosting plan to create.

    3. LOCATION: Specifies the Azure location in which to create the DocumentDB and web app resources.

    4. DATABASEACCOUNTNAME: Specifies the name of the DocumentDB account to create.

      Screenshot of the template deployment UI

  5. Choose an existing Resource group or provide a name to make a new resource group, and choose a location for the resource group. Screenshot of the template deployment UI

  6. Click Review legal terms, Purchase, and then click Create to begin the deployment. Select Pin to dashboard so the resulting deployment is easily visible on your Azure portal home page. Screenshot of the template deployment UI

  7. When the deployment finishes, the Resource group blade will open. Screenshot of the resource group blade

  8. To use the application, simply navigate to the web app URL (in the example above, the URL would be http://mydemodocdbwebapp.azurewebsites.net). You'll see the following web application:

    Sample Todo application

  9. Go ahead and create a couple of tasks in the web app and then return to the Resource group blade in the Azure portal. Click the DocumentDB account resource in the Resources list and then click Query Explorer. Screenshot of the Summary lens with the myotherdocumentdbwebapp web app highlighted

  10. Run the default query, "SELECT * FROM c" and inspect the results. Notice that the query has retrieved the JSON representation of the todo items you created in step 7 above. Feel free to experiment with queries; for example, try running SELECT * FROM c WHERE c.isComplete = true to return all todo items which have been marked as complete.

    Screenshot of the Query Explorer and Results blades showing the query results

  11. Feel free to explore the DocumentDB portal experience or modify the sample Todo application. When you're ready, let's deploy another template.

Step 3: Deploy the Document account and web app sample

Now let's deploy our second template. This template is useful to show how you can inject DocumentDB connection information such as account endpoint and master key into a web app as application settings or as a custom connection string. For example, perhaps you have your own web application that you would like to deploy with a DocumentDB account and have the connection information automatically populated during deployment.

Tip

The template does not validate that the web app name and DocumentDB account name entered below are a) valid and b) available. It is highly recommended that you verify the availability of the names you plan to supply prior to submitting the deployment.

  1. In the Azure Portal, click New and search for "Template deployment". Screenshot of the template deployment UI

  2. Select the Template deployment item and click Create Screenshot of the template deployment UI

  3. Click Edit template, paste the contents of the DocDBWebSite.json template file, and click Save. Screenshot of the template deployment UI

  4. Click Edit parameters, provide values for each of the mandatory parameters, and click OK. The parameters are as follows:

    1. SITENAME: Specifies the App Service web app name and is used to construct the URL that you will use to access the web app (e.g. if you specify "mydemodocdbwebapp", then the URL by which you will access the web app will be mydemodocdbwebapp.azurewebsites.net).

    2. HOSTINGPLANNAME: Specifies the name of App Service hosting plan to create.

    3. LOCATION: Specifies the Azure location in which to create the DocumentDB and web app resources.

    4. DATABASEACCOUNTNAME: Specifies the name of the DocumentDB account to create.

      Screenshot of the template deployment UI

  5. Choose an existing Resource group or provide a name to make a new resource group, and choose a location for the resource group. Screenshot of the template deployment UI

  6. Click Review legal terms, Purchase, and then click Create to begin the deployment. Select Pin to dashboard so the resulting deployment is easily visible on your Azure portal home page. Screenshot of the template deployment UI

  7. When the deployment finishes, the Resource group blade will open. Screenshot of the resource group blade

  8. Click the Web App resource in the Resources list and then click Application settings Screenshot of the resource group

  9. Note how there are application settings present for the DocumentDB endpoint and each of the DocumentDB master keys. Screenshot of application settings

  10. Feel free to continue exploring the Azure Portal, or follow one of our DocumentDB samples to create your own DocumentDB application.

Next steps

Congratulations! You've deployed DocumentDB, App Service web app and a sample web application using Azure Resource Manager templates.

  • To learn more about DocumentDB, click here.
  • To learn more about Azure App Service Web apps, click here.
  • To learn more about Azure Resource Manager templates, click here.

What's changed

Note

If you want to get started with Azure App Service before signing up for an Azure account, go to Try App Service, where you can immediately create a short-lived starter web app in App Service. No credit cards required; no commitments.