Skip to content

Commit 8e5ed4d

Browse files
committed
Moving code section
1 parent d5a426e commit 8e5ed4d

File tree

1 file changed

+75
-72
lines changed

1 file changed

+75
-72
lines changed

articles/defender-for-iot/organizations/automate-sensor-disconnection-alerts.md

Lines changed: 75 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,80 @@ Before you start, make sure you have:
4747

4848
## Paste the playbook code and modify fields
4949

50-
1. Select **Logic app code view**, and paste the following code into the editor:
50+
1. Select **Logic app code view**, and paste the [playbook code](#playbook-code) into the editor.
51+
1. Modify these fields in the code:
52+
53+
- Under the `post` body, in the `To` field, type the email to which you want to receive the notifications.
54+
- Under the `office365` parameter:
55+
- Under the `id` field, replace `Replace with subscription` with the ID of the subscription running Microsoft Sentinel, for example:
56+
57+
```json
58+
"id": "/subscriptions/exampleID/providers/Microsoft.Web/locations/eastus/managedApis/office365"
59+
```
60+
61+
- Under the `connectionId` field, replace `Replace with subscription` with your subscription ID, and replace `Replace with RG name` with your resource group name, for example:
62+
63+
```json
64+
"connectionId": "/subscriptions/exampleID/resourceGroups/ExampleResourceGroup/providers/Microsoft.Web/connections/office365"
65+
```
66+
67+
1. Select **Save**.
68+
1. Go back to the **Logic app designer** to view the logic that the playbook follows.
69+
70+
:::image type="content" source="media/automate-sensor-disconnection-alerts/playbook-logic.png" alt-text="Screenshot of a of the playbook logic for Defender for IoT sensor disconnection alerts." lightbox="media/automate-sensor-disconnection-alerts/playbook-logic.png":::
71+
72+
## Set up managed identity for your subscription
73+
74+
To give the playbook permission to run Keyword Query Language (KQL) queries and get relevant sensor data:
75+
76+
1. In the Azure portal, select **Subscriptions**.
77+
1. Select the subscription running Microsoft Sentinel and select **Access Control (IAM)**.
78+
1. Select **Add > Add Role Assignment**.
79+
1. Search for the **Reader** role.
80+
1. In the **Role** tab, select **Next**.
81+
1. In the **Members** tab, under **Assign access to**, select **Managed Identity**.
82+
1. In the **Select Managed identities** window:
83+
1. Under **Subscription**, select the subscription running Microsoft Sentinel.
84+
1. Under **Managed identity**, select your playbook's name.
85+
1. Under **Select**, select the name of the automation rule you created and select **Select**.
86+
87+
:::image type="content" source="media/automate-sensor-disconnection-alerts/playbook-permissions-managed-identity-members.png" alt-text="Screenshot of a of setting up members for a managed identity while creating a Defender for IoT sensor disconnection alerts playbook." lightbox="media/automate-sensor-disconnection-alerts/playbook-permissions-managed-identity-members.png":::
88+
89+
1. In the editor, select **HTTP2** and verify that the **Authentication Type** is set to **Managed Identity**.
90+
91+
:::image type="content" source="media/automate-sensor-disconnection-alerts/playbook-permissions-managed-identity.png" alt-text="Screenshot of sending up a managed identity for the Defender for IoT sensor disconnection alerts playbook." lightbox="media/automate-sensor-disconnection-alerts/playbook-permissions-managed-identity.png":::
92+
93+
## Verify the sensor status
94+
95+
If you can't create the playbook successfully, run a KQL query in Azure Resource Graph to confirm that the sensor is offline.
96+
97+
1. In the Azure portal, search for *Azure resource graph explorer*.
98+
1. Run the following query:
99+
100+
```kusto
101+
iotsecurityresources
102+
103+
| where type =='microsoft.iotsecurity/locations/sites/sensors'
104+
105+
|extend Status=properties.sensorStatus
106+
107+
|extend LastConnectivityTime=properties.connectivityTime
108+
109+
|extend Status=iif(LastConnectivityTime<ago(5m),'Disconnected',Status)
110+
111+
|project SensorName=name, Status, LastConnectivityTime
112+
113+
|where Status == 'Disconnected'
114+
```
115+
116+
If the sensor has been offline for at least five minutes, the sensor status is **Disconnected**.
117+
118+
> [!NOTE]
119+
> It takes up to 15 minutes for the sensor to synchronize the status update with the cloud. This means that the sensor needs to be offline for at least 15 minutes before the status is updated.
120+
121+
### Playbook code
122+
123+
Copy this code and return to the [paste the playbook code](#paste-the-playbook-code-and-modify-fields) step.
51124

52125
```json
53126
{
@@ -433,77 +506,7 @@ Before you start, make sure you have:
433506
}
434507

435508
}
436-
```
437-
1. Modify these fields in the code:
438-
439-
- Under the `post` body, in the `To` field, type the email to which you want to receive the notifications.
440-
- Under the `office365` parameter:
441-
- Under the `id` field, replace `Replace with subscription` with the ID of the subscription running Microsoft Sentinel, for example:
442-
443-
```json
444-
"id": "/subscriptions/exampleID/providers/Microsoft.Web/locations/eastus/managedApis/office365"
445-
```
446-
447-
- Under the `connectionId` field, replace `Replace with subscription` with your subscription ID, and replace `Replace with RG name` with your resource group name, for example:
448-
449-
```json
450-
"connectionId": "/subscriptions/exampleID/resourceGroups/ExampleResourceGroup/providers/Microsoft.Web/connections/office365"
451-
```
452-
453-
1. Select **Save**.
454-
1. Go back to the **Logic app designer** to view the logic that the playbook follows.
455-
456-
:::image type="content" source="media/automate-sensor-disconnection-alerts/playbook-logic.png" alt-text="Screenshot of a of the playbook logic for Defender for IoT sensor disconnection alerts." lightbox="media/automate-sensor-disconnection-alerts/playbook-logic.png":::
457-
458-
## Set up managed identity for your subscription
459-
460-
To give the playbook permission to run Keyword Query Language (KQL) queries and get relevant sensor data:
461-
462-
1. In the Azure portal, select **Subscriptions**.
463-
1. Select the subscription running Microsoft Sentinel and select **Access Control (IAM)**.
464-
1. Select **Add > Add Role Assignment**.
465-
1. Search for the **Reader** role.
466-
1. In the **Role** tab, select **Next**.
467-
1. In the **Members** tab, under **Assign access to**, select **Managed Identity**.
468-
1. In the **Select Managed identities** window:
469-
1. Under **Subscription**, select the subscription running Microsoft Sentinel.
470-
1. Under **Managed identity**, select your playbook's name.
471-
1. Under **Select**, select the name of the automation rule you created and select **Select**.
472-
473-
:::image type="content" source="media/automate-sensor-disconnection-alerts/playbook-permissions-managed-identity-members.png" alt-text="Screenshot of a of setting up members for a managed identity while creating a Defender for IoT sensor disconnection alerts playbook." lightbox="media/automate-sensor-disconnection-alerts/playbook-permissions-managed-identity-members.png":::
474-
475-
1. In the editor, select **HTTP2** and verify that the **Authentication Type** is set to **Managed Identity**.
476-
477-
:::image type="content" source="media/automate-sensor-disconnection-alerts/playbook-permissions-managed-identity.png" alt-text="Screenshot of sending up a managed identity for the Defender for IoT sensor disconnection alerts playbook." lightbox="media/automate-sensor-disconnection-alerts/playbook-permissions-managed-identity.png":::
478-
479-
## Verify the sensor status
480-
481-
If you can't create the playbook successfully, run a KQL query in Azure Resource Graph to confirm that the sensor is offline.
482-
483-
1. In the Azure portal, search for *Azure resource graph explorer*.
484-
1. Run the following query:
485-
486-
```kusto
487-
iotsecurityresources
488-
489-
| where type =='microsoft.iotsecurity/locations/sites/sensors'
490-
491-
|extend Status=properties.sensorStatus
492-
493-
|extend LastConnectivityTime=properties.connectivityTime
494-
495-
|extend Status=iif(LastConnectivityTime<ago(5m),'Disconnected',Status)
496-
497-
|project SensorName=name, Status, LastConnectivityTime
498-
499-
|where Status == 'Disconnected'
500-
```
501-
502-
If the sensor has been offline for at least five minutes, the sensor status is **Disconnected**.
503-
504-
> [!NOTE]
505-
> It takes up to 15 minutes for the sensor to synchronize the status update with the cloud. This means that the sensor needs to be offline for at least 15 minutes before the status is updated.
506-
509+
```
507510
## Next steps
508511

509512
> [!div class="nextstepaction"]

0 commit comments

Comments
 (0)