Skip to content

Commit 5fff988

Browse files
committed
Edits to create a new function app
1 parent 4b50c76 commit 5fff988

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

articles/digital-twins/how-to-integrate-time-series-insights.md

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,21 @@ Also, take note of the following values to use them later to create a Time Serie
161161

162162
## Create a function
163163

164-
> [!TIP]
165-
> It is optional to create a function to visualize twin data in the Time Series Insights explorer.
166-
167164
In this section, you'll create an Azure function that will convert twin update events from their original form as JSON Patch documents to JSON objects, containing only updated and added values from your twins.
168165

169-
### Step 1: Add a new function
166+
### Step 1: Create function app
167+
168+
First, create a new function app project in Visual Studio. For instructions on how to do this, see the [**Create a function app in Visual Studio**](how-to-create-azure-function.md#create-a-function-app-in-visual-studio) section of the *How-to: Set up a function for processing data* article.
169+
170+
Save the function app name to use later to configure app setting for the two event hubs.
171+
172+
### Step 2: Add a new function
170173

171-
Inside your function app project created in the [prerequisites](#prerequisites) section, create a new Azure function called *ProcessDTUpdatetoTSI.cs* to update device telemetry events to the Time Series Insights. The function type will be **Event Hub trigger**.
174+
Create a new Azure function called *ProcessDTUpdatetoTSI.cs* to update device telemetry events to the Time Series Insights. The function type will be **Event Hub trigger**.
172175

173176
:::image type="content" source="media/how-to-integrate-time-series-insights/create-event-hub-trigger-function.png" alt-text="Screenshot of Visual Studio to create a new Azure function of type event hub trigger.":::
174177

175-
### Step 2: Fill in function code
178+
### Step 3: Fill in function code
176179

177180
Add the following packages to your project:
178181
* [Microsoft.Azure.WebJobs](https://www.nuget.org/packages/Microsoft.Azure.WebJobs/)
@@ -185,30 +188,35 @@ Replace the code in the *ProcessDTUpdatetoTSI.cs* file with the following code:
185188

186189
Save your function code.
187190

188-
### Step 3: Publish the function app to Azure
191+
### Step 4: Publish the function app to Azure
189192

190-
Next, **publish** the new Azure function.
191-
[!INCLUDE [digital-twins-publish-and-configure-function-app.md](../../includes/digital-twins-publish-and-configure-function-app.md)]
193+
Publish the project with *ProcessDTUpdatetoTSI.cs* function to a function app in Azure.
192194

193-
### Configure twins hub app setting
195+
For instructions on how to do this, see the section [**Publish the function app to Azure**](how-to-create-azure-function.md#publish-the-function-app-to-azure) of the *How-to: Set up a function for processing data* article.
194196

195-
Use the twins hub **primaryConnectionString** value that you saved earlier to create an app setting in your function app that contains your connection string:
197+
### Step 5: Security access for the function app
198+
199+
Next, **assign an access role** for the function and **configure the application settings** so that it can access your Azure Digital Twins instance. For instructions on how to do this, see the section [**Set up security access for the function app**](how-to-create-azure-function.md#set-up-security-access-for-the-function-app) of the *How-to: Set up a function for processing data* article.
200+
201+
### Step 6: Configure app setting for the two event hubs
202+
203+
Next, you'll configure app settings for twins hub and time series hub.
204+
205+
Use the twins hub **primaryConnectionString** value that you saved earlier to create an app setting in your function app that contains your connection string:
196206

197207
```azurecli-interactive
198-
az functionapp config appsettings set --settings "EventHubAppSetting-Twins=<primaryConnectionString-value-from-above>" -g <your-resource-group> -n <your-App-Service-(function-app)-name>
208+
az functionapp config appsettings set --settings "EventHubAppSetting-Twins=<your-twins-hub-primaryConnectionString-value-from-earlier>" -g <your-resource-group> -n <your-App-Service-(function-app)-name>
199209
```
200210

201-
### Configure time series hub app setting
202-
203-
Use the time series hub **primaryConnectionString** value that you saved earlier to create an app setting in your function app that contains your connection string:
211+
Use the time series hub **primaryConnectionString** value that you saved earlier to create an app setting in your function app that contains your connection string:
204212

205213
```azurecli-interactive
206-
az functionapp config appsettings set --settings "EventHubAppSetting-TSI=<primaryConnectionString-from above>" -g <your-resource-group> -n <your-App-Service-(function-app)-name>
214+
az functionapp config appsettings set --settings "EventHubAppSetting-TSI=<your-time-series-hub- primaryConnectionString-value-from-earlier>" -g <your-resource-group> -n <your-App-Service-(function-app)-name>
207215
```
208216

209217
## Create and connect a Time Series Insights instance
210218

211-
You will set up Time Series Insights instance to receive data from your time series hub. For more details about this process, see [*Tutorial: Set up an Azure Time Series Insights Gen2 PAYG environment*](../time-series-insights/tutorial-set-up-environment.md). Follow the steps below to create a time series insights.
219+
In this section, you'll set up Time Series Insights instance to receive data from your time series hub. For more details about this process, see [*Tutorial: Set up an Azure Time Series Insights Gen2 PAYG environment*](../time-series-insights/tutorial-set-up-environment.md). Follow the steps below to create a time series insights environment.
212220

213221
1. In the [Azure portal](https://portal.azure.com), search for *Time Series Insights environments*, and select the **Add** button. Choose the following options to create the time series environment.
214222

@@ -253,7 +261,7 @@ To begin sending data to Time Series Insights, you'll need to start updating the
253261
Use the following CLI command to update the twin property. If you followed [*How-to: Ingest IoT Hub data*](how-to-ingest-iot-hub-data.md#add-a-model-and-twin) article to create a model and twin, the `twin_id` value will be *thermostat67*.
254262

255263
```azurecli-interactive
256-
az dt twin update -n <your-azure-digital-twins-instance-name> --twin-id {twin_id} --json-patch '{"op":"replace", "path":"/Temperature", "value": 20.5}'
264+
az dt twin update -n <your-azure-digital-twins-instance-name> --twin-id {twin_id} --json-patch '{"op":"replace", "path":"/Temperature", "value": 20.5}'
257265
```
258266

259267
**Repeat the command at least 4 more times with different temperature values**, to create several data points that can be observed later in the Time Series Insights environment.

0 commit comments

Comments
 (0)