You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-functions/functions-create-cosmos-db-triggered-function.md
+23-22Lines changed: 23 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,14 +4,14 @@ description: Use Azure Functions to create a serverless function that is invoked
4
4
5
5
ms.assetid: bc497d71-75e7-47b1-babd-a060a664adca
6
6
ms.topic: how-to
7
-
ms.date: 10/02/2018
7
+
ms.date: 04/28/2020
8
8
ms.custom: cc996988-fb4f-47
9
9
---
10
10
# Create a function triggered by Azure Cosmos DB
11
11
12
12
Learn how to create a function triggered when data is added to or changed in Azure Cosmos DB. To learn more about Azure Cosmos DB, see [Azure Cosmos DB: Serverless database computing using Azure Functions](../cosmos-db/serverless-computing-database.md).
13
13
14
-

14
+
:::image type="content" source="./media/functions-create-cosmos-db-triggered-function/quickstart-completed.png" alt-text="Azure Cosmos DB code":::
15
15
16
16
## Prerequisites
17
17
@@ -22,6 +22,9 @@ To complete this tutorial:
22
22
> [!NOTE]
23
23
> [!INCLUDE [SQL API support only](../../includes/functions-cosmosdb-sqlapi-note.md)]
24
24
25
+
## Sign in to Azure
26
+
Sign in to the [Azure portal](https://portal.azure.com/) with your Azure account.
27
+
25
28
## Create an Azure Cosmos DB account
26
29
27
30
You must have an Azure Cosmos DB account that uses the SQL API before you create the trigger.
@@ -38,35 +41,33 @@ Next, you create a function in the new function app.
38
41
39
42
## Create Azure Cosmos DB trigger
40
43
41
-
1. Expand your function app and click the **+** button next to **Functions**. If this is the first function in your function app, select **In-portal** then **Continue**. Otherwise, go to step three.
42
-
43
-

44
+
1. In your function app, select **Functions** from the left menu, and then select **Add** from the top menu.
44
45
45
-
1.Choose **More templates** then **Finish and view templates**.
46
+
1.On the **New Function**page, enter `cosmos` in the search field and then choose the **Azure Cosmos DB trigger** template.
46
47
47
-

48
+
:::image type="content" source="./media/functions-create-cosmos-db-triggered-function/function-choose-cosmos.png" alt-text="Functions page in the Azure portal":::
48
49
49
-
1. In the search field, type `cosmos` and then choose the **Azure Cosmos DB trigger** template.
50
50
51
-
1.If prompted, select **Install** to install the Azure Cosmos DB extension in the function app. After installation succeeds, select **Continue**.
51
+
1.Configure the new trigger with the settings as specified in the following table:
|**New Function**| Accept the default name | The name of the function. |
56
+
|**Cosmos DB account connection**| Accept the default new name | Select **New**, the **Database Account** you created earlier, and then **OK**. This action creates an application setting for your account connection. This setting is used by the binding to connection to the database. |
57
+
|**Database name**| Tasks | Name of the database that includes the collection to be monitored. |
58
+
|**Collection name**| Items | Name of the collection to be monitored. |
59
+
|**Collection name for leases**| leases | Name of the collection to store the leases. |
60
+
|**Create lease collection if it does not exist**| Yes | Checks for existence of the lease collection and automatically creates it. |
54
61
55
-
1. Configure the new trigger with the settings as specified in the table below the image.
62
+
:::image type="content" source="./media/functions-create-cosmos-db-triggered-function/functions-cosmosdb-trigger-settings.png" alt-text="Create the Azure Cosmos DB triggered function":::
56
63
57
-

|**Name**| Default | Use the default function name suggested by the template.|
62
-
|**Azure Cosmos DB account connection**| New setting | Select **New**, then choose your **Subscription**, the **Database account** you created earlier, and **Select**. This creates an application setting for your account connection. This setting is used by the binding to connection to the database. |
63
-
|**Container name**| Items | Name of container to be monitored. |
64
-
|**Create lease container if it doesn't exist**| Checked | The container doesn't already exist, so create it. |
65
-
|**Database name**| Tasks | Name of database with the container to be monitored. |
66
+
Azure creates the Cosmos DB trigger function.
66
67
67
-
1.Click **Create** to create your Azure Cosmos DB triggered function. After the function is created, the template-based function code is displayed.
68
+
1.To display the template-based function code, select **Code + Test**.
68
69
69
-

70
+
:::image type="content" source="./media/functions-create-cosmos-db-triggered-function/function-cosmosdb-template.png" alt-text="Cosmos DB function template in C#":::
70
71
71
72
This function template writes the number of documents and the first document ID to the logs.
72
73
@@ -105,7 +106,7 @@ After the container specified in the function binding exists, you can test the f
105
106
106
107
1. Expand the new **Items** container in Data Explorer, choose **Items**, then select **New Item**.
107
108
108
-

109
+
:::image type="content" source="./media/functions-create-cosmos-db-triggered-function/create-item-in-container.png" alt-text="Create an item in Items container":::
109
110
110
111
1. Replace the contents of the new item with the following content, then choose **Save**.
Copy file name to clipboardExpand all lines: includes/cosmos-db-create-dbaccount.md
+3-9Lines changed: 3 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,17 +10,11 @@
10
10
ms.custom: include file
11
11
---
12
12
13
-
1.Go to the [Azure portal](https://portal.azure.com/) to create an Azure Cosmos DB account. At your homepage choose **Create a resource** from the **Azure services** panel.
13
+
1.From the Azure portal menu or the **Home page**, select **Create a resource**.
14
14
15
-

15
+
1. On the **New** page, search for and select **Azure Cosmos DB**.
0 commit comments