Skip to content

Commit 193a096

Browse files
committed
updated steps and screenshots
1 parent a1a8d73 commit 193a096

14 files changed

+56
-20
lines changed

articles/event-grid/custom-event-to-function.md

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,87 @@
11
---
22
title: 'Quickstart: Send custom events to Azure Function - Event Grid'
33
description: 'Quickstart: Use Azure Event Grid and Azure CLI or portal to publish a topic, and subscribe to that event. An Azure Function is used for the endpoint.'
4-
ms.date: 09/28/2021
4+
ms.date: 11/02/2022
55
ms.topic: quickstart
66
ms.custom: mode-other, devx-track-azurecli
77
ms.devlang: azurecli
88
---
99

1010
# Quickstart: Route custom events to an Azure Function with Event Grid
1111

12-
Azure Event Grid is an eventing service for the cloud. Azure Functions is one of the supported event handlers. In this article, you use the Azure portal to create a custom topic, subscribe to the custom topic, and trigger the event to view the result. You send the events to an Azure Function.
12+
[Azure Event Grid](overview.md) is an eventing service for the cloud. Azure Functions is one of the [supported event handlers](event-handlers.md). In this article, you use the Azure portal to create a custom topic, subscribe to the custom topic, and trigger the event to view the result. You send the events to an Azure Function.
1313

1414
[!INCLUDE [quickstarts-free-trial-note.md](../../includes/quickstarts-free-trial-note.md)]
1515

16-
## Create Azure Function
16+
## Create Azure function app
17+
18+
1. Sign in to the [Azure portal](https://portal.azure.com).
19+
1. On the left navigational menu, select **All services**.
20+
1. Select **Compute** in the list of **Categories**.
21+
1. Hover (not select) the mouse over **Function App**, and select **Create**.
22+
23+
:::image type="content" source="./media/custom-event-to-function/create-function-app-link.png" lightbox="./media/custom-event-to-function/create-function-app-link.png" alt-text="Screenshot showing the select of **Create** link for a **Function App**.":::
24+
1. On the **Basics** page of the **Create Function App** wizard, follow these steps:
25+
1. Select your **Azure subscription** in which you want to create the function app.
26+
1. Create a new **resource group** or select an existing resource group.
27+
1. Specify a **name** for the function app.
28+
1. Select **.NET** for **Runtime stack**.
29+
1. Select the **region** closest to you.
30+
1. Select **Next: Hosting** at the bottom of the page.
31+
32+
:::image type="content" source="./media/custom-event-to-function/create-function-app-page.png" alt-text="Screenshot showing the **Basics** tab of the **Create Function App** page.":::
33+
1. On the **Hosting** page, create a new storage account or select an existing storage account to be associated with the function app, and then select **Review + create** at the bottom of the page.
34+
35+
:::image type="content" source="./media/custom-event-to-function/create-function-app-hosting-page.png" alt-text="Screenshot showing the **Hosting** tab of the **Create Function App** page.":::
36+
1. On the **Review + create** page, review settings, and select **Create** at the bottom of the page to create the function app.
37+
1. Once the deployment is successful, select **Go to resource** to navigate to the home page for the function app.
38+
39+
## Create a function
1740
Before subscribing to the custom topic, create a function to handle the events.
1841

19-
1. Create a function app using instructions from [Create a function app](../azure-functions/functions-get-started.md).
2042
1. On the **Function App** page, select **Functions** on the left menu.
21-
1. Select **+Create** on the toolbar to create a function.
43+
1. Select **+ Create** on the toolbar to create a function.
44+
45+
:::image type="content" source="./media/custom-event-to-function/create-function-link.png" alt-text="Screenshot showing the selection of **Create function** link.":::
46+
2247
1. On the **Create Function** page, follow these steps:
2348
1. This step is optional. For **Development environment**, select the development environment that you want to use to work with the function code.
24-
1. Select **Azure Event Grid Trigger** in the **Select a template** section.
25-
1. Enter a name for the function. In this example, it's **HandleEventsFunc**.
49+
1. Select **Azure Event Grid Trigger** in the **Select a template** section. Use the scroll bar right to the list to scroll down if needed.
50+
1. In the **Template details** section in the bottom pane, enter a name for the function. In this example, it's **HandleEventsFunc**.
2651

2752
:::image type="content" source="./media/custom-event-to-function/function-event-grid-trigger.png" lightbox="./media/custom-event-to-function/function-event-grid-trigger.png" alt-text="Select Event Grid trigger.":::
28-
4. Use the **Code + Test** page to see the existing code for the function and update it.
53+
4. On the **Function** page for the **HandleEventsFunc**, select **Code + Test** on the left navigational menu. You can see the existing code for the function and update it on this page.
2954

3055
:::image type="content" source="./media/custom-event-to-function/function-code-test-menu.png" alt-text="Image showing the selection Code + Test menu for an Azure function.":::
3156

32-
[!INCLUDE [event-grid-register-provider-portal.md](../../includes/event-grid-register-provider-portal.md)]
3357

3458
## Create a custom topic
3559

36-
An event grid topic provides a user-defined endpoint that you post your events to.
60+
An Event Grid topic provides a user-defined endpoint that you post your events to.
3761

38-
1. Sign in to [Azure portal](https://portal.azure.com/).
39-
2. Select **All services** on the left navigational menu, search for **Event Grid**, and select **Event Grid Topics**.
62+
1. On a new tab of the web browser window, sign in to [Azure portal](https://portal.azure.com/).
63+
2. In the search bar at the topic, search for **Event Grid Topics**, and select **Event Grid Topics**.
4064

41-
:::image type="content" source="./media/custom-event-to-function/select-event-grid-topics.png" alt-text="Image showing the selection of Event Grid Topics.":::
42-
3. On the **Event Grid Topics** page, select **+ Add** on the toolbar.
65+
:::image type="content" source="./media/custom-event-to-function/select-event-grid-topics.png" alt-text="Image showing the selection of Event Grid topics.":::
66+
3. On the **Event Grid Topics** page, select **+ Create** on the command bar.
4367

44-
:::image type="content" source="./media/custom-event-to-function/add-event-grid-topic-button.png" alt-text="Image showing the Create button to create an event grid topic.":::
68+
:::image type="content" source="./media/custom-event-to-function/add-event-grid-topic-button.png" alt-text="Screenshot showing the Create button to create an Event Grid topic.":::
4569
4. On the **Create Topic** page, follow these steps:
4670
1. Select your **Azure subscription**.
4771
2. Select the same **resource group** from the previous steps.
4872
3. Provide a unique **name** for the custom topic. The topic name must be unique because it's represented by a DNS entry. Don't use the name shown in the image. Instead, create your own name - it must be between 3-50 characters and contain only values a-z, A-Z, 0-9, and "-".
49-
4. Select a **location** for the event grid topic.
73+
4. Select a **location** for the Event Grid topic.
5074
5. Select **Review + create**.
5175

5276
:::image type="content" source="./media/custom-event-to-function/create-custom-topic.png" alt-text="Image showing the Create Topic page.":::
5377
1. On the **Review + create** page, review settings and select **Create**.
54-
5. After the custom topic has been created, select **Go to resource** link to see the following Event Grid Topic page for the topic you created.
78+
5. After the custom topic has been created, select **Go to resource** link to see the following Event Grid topic page for the topic you created.
5579

5680
:::image type="content" source="./media/custom-event-to-function/event-grid-topic-home-page.png" alt-text="Image showing the home page for your Event Grid custom topic.":::
5781

5882
## Subscribe to custom topic
5983

60-
You subscribe to an event grid topic to tell Event Grid which events you want to track, and where to send the events.
84+
You subscribe to an Event Grid topic to tell Event Grid which events you want to track, and where to send the events.
6185

6286
1. Now, on the **Event Grid Topic** page for your custom topic, select **+ Event Subscription** on the toolbar.
6387

@@ -89,15 +113,24 @@ The first example uses Azure CLI. It gets the URL and key for the custom topic,
89113
1. In the Azure portal, select **Cloud Shell**. Select **Bash** in the top-left corner of the Cloud Shell window.
90114

91115
:::image type="content" source="./media/custom-event-quickstart-portal/cloud-shell-bash.png" alt-text="Image showing Cloud Shell - Bash window":::
116+
1. Set the `topicname` and `resourcegroupname` variables that will be used in the commands.
117+
118+
```azurecli
119+
topicname="TOPICNAME"
120+
```
121+
122+
```azurecli
123+
resourcegroupname="RESOURCEGROUPNAME"
124+
```
92125
1. Run the following command to get the **endpoint** for the topic: After you copy and paste the command, update the **topic name** and **resource group name** before you run the command.
93126
94127
```azurecli
95-
endpoint=$(az eventgrid topic show --name <topic name> -g <resource group name> --query "endpoint" --output tsv)
128+
endpoint=$(az eventgrid topic show --name $topicname -g $resourcegroupname --query "endpoint" --output tsv)
96129
```
97130
2. Run the following command to get the **key** for the custom topic: After you copy and paste the command, update the **topic name** and **resource group** name before you run the command.
98131
99132
```azurecli
100-
key=$(az eventgrid topic key list --name <topic name> -g <resource group name> --query "key1" --output tsv)
133+
key=$(az eventgrid topic key list --name $topicname -g $resourcegroupname --query "key1" --output tsv)
101134
```
102135
3. Copy the following statement with the event definition, and press **ENTER**.
103136
@@ -118,6 +151,9 @@ The second example uses PowerShell to perform similar steps.
118151
119152
```powershell
120153
$resourceGroupName = <resource group name>
154+
```
155+
156+
```powershell
121157
$topicName = <topic name>
122158
```
123159
3. Run the following commands to get the **endpoint** and the **keys** for the topic:
25.9 KB
Loading
6.68 KB
Loading
24.3 KB
Loading
75 KB
Loading
62.1 KB
Loading
41.4 KB
Loading
2.14 KB
Loading
-3.33 KB
Loading
1.43 KB
Loading

0 commit comments

Comments
 (0)