Skip to content

Commit a5dccbb

Browse files
authored
Merge pull request #202519 from kgremban/jun21-ducli
Device Update CLI release
2 parents 9251bf3 + b95241f commit a5dccbb

21 files changed

+429
-136
lines changed

articles/iot-hub-device-update/configure-private-endpoints.md

Lines changed: 175 additions & 58 deletions
Large diffs are not rendered by default.

articles/iot-hub-device-update/create-device-update-account.md

Lines changed: 172 additions & 51 deletions
Large diffs are not rendered by default.

articles/iot-hub-device-update/device-update-log-collection.md

Lines changed: 76 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,53 +3,107 @@ title: Device Update for Azure IoT Hub log collection | Microsoft Docs
33
description: Device Update for IoT Hub enables remote collection of diagnostic logs from connected IoT devices.
44
author: lichris
55
ms.author: lichris
6-
ms.date: 12/22/2021
6+
ms.date: 06/23/2022
77
ms.topic: how-to
88
ms.service: iot-hub-device-update
99
---
1010

1111
# Remotely collect diagnostic logs from devices using Device Update for IoT Hub
12+
1213
Learn how to initiate a Device Update for IoT Hub log operation and view collected logs within Azure blob storage.
1314

1415
## Prerequisites
15-
* [Access to an IoT Hub with Device Update for IoT Hub enabled](create-device-update-account.md).
16+
17+
# [Azure portal](#tab/portal)
18+
19+
* [Access to an IoT Hub with Device Update for IoT Hub enabled](create-device-update-account.md).
1620
* An IoT device (or simulator) [provisioned for Device Update](device-update-agent-provisioning.md) within IoT Hub and implementing the Diagnostic Interface.
1721
* An [Azure Blob storage account](../storage/common/storage-account-create.md) under the same subscription as your Device Update for IoT Hub account.
1822

1923
> [!NOTE]
2024
> The remote log collection feature is currently compatible only with devices that implement the Diagnostic Interface and are able to upload files to Azure Blob storage. The reference agent implementation also expects the device to write log files to a user-specified file path on the device.
2125
26+
# [Azure CLI](#tab/cli)
27+
28+
* [Access to an IoT Hub with Device Update for IoT Hub enabled](create-device-update-account.md).
29+
30+
* An IoT device (or simulator) [provisioned for Device Update](device-update-agent-provisioning.md) within IoT Hub and implementing the Diagnostic Interface.
31+
32+
* An [Azure Blob storage account](../storage/common/storage-account-create.md) under the same subscription as your Device Update for IoT Hub account.
33+
34+
* An Azure CLI environment:
35+
36+
* Use the Bash environment in [Azure Cloud Shell](../cloud-shell/quickstart.md).
37+
38+
[![Launch Cloud Shell in a new window](../../includes/media/cloud-shell-try-it/hdi-launch-cloud-shell.png)](https://shell.azure.com)
39+
40+
* Or, if you prefer to run CLI reference commands locally, [install the Azure CLI](/cli/azure/install-azure-cli)
41+
42+
* Sign in to the Azure CLI by using the [az login](/cli/azure/reference-index#az-login) command.
43+
* Run [az version](/cli/azure/reference-index#az-version) to find the version and dependent libraries that are installed. To upgrade to the latest version, run [az upgrade](/cli/azure/reference-index#az-upgrade).
44+
* When prompted, install Azure CLI extensions on first use. The commands in this article use the **azure-iot** extension. Run `az extension update --name azure-iot` to make sure you're using the latest version of the extension.
45+
46+
> [!NOTE]
47+
> The remote log collection feature is currently compatible only with devices that implement the Diagnostic Interface and are able to upload files to Azure Blob storage. The reference agent implementation also expects the device to write log files to a user-specified file path on the device.
48+
49+
---
50+
2251
## Link your Azure Blob storage account to your Device Update instance
2352

24-
In order to use the remote log collection feature, you must first link an Azure Blob storage account with your Device Update instance. This Azure Blob storage account is where your devices will upload diagnostic logs to.
53+
In order to use the remote log collection feature, you must first link an Azure Blob storage account with your Device Update instance. This Azure Blob storage account is where your devices will upload diagnostic logs to.
54+
55+
# [Azure portal](#tab/portal)
56+
57+
1. In the [Azure portal](https://portal.azure.com), navigate to your Device Update for IoT Hub account.
58+
59+
2. Select **Instances** under the **Instance Management** section of the navigation pane.
60+
61+
3. Select your Device Update instance from the list, then **Configure Diagnostics**.
62+
63+
4. Select the **Customer Diagnostics** tab, then **Select Azure Storage Account**.
64+
65+
5. Choose your desired storage account from the list and select **Save.**
2566

26-
1. Navigate to your Device Update for IoT Hub resource.
67+
6. Once back on the instance list, select **Refresh** periodically until the instance's provisioning state shows "Succeeded." This process usually takes 2-3 minutes.
2768

28-
2. Select "Instance" under the "Instance Management" section of the navigation pane.
69+
# [Azure CLI](#tab/cli)
2970

30-
3. Select your Device Update instance from the list, then "Configure Diagnostics."
71+
Use the [az iot device-update instance create](/cli/azure/iot/device-update/instance#az-iot-device-update-instance-create) command to configure diagnostics for your Device Update instance.
3172

32-
4. Select the "Customer Diagnostics" tab, then "Select Azure Storage Account."
73+
>[!TIP]
74+
>You can use the `az iot device-update instance create` command on an existing Device Update instances and it will configure the instance with the updated parameters.
3375
34-
5. Choose your desired storage account from the list and select "Save."
76+
Replace the following placeholders with your own information:
3577

36-
6. Once back on the instance list, select "Refresh" periodically until the instance's Provisioning State shows "Succeeded." This usually takes 2-3 minutes.
78+
* *\<account_name>*: The name of your Device Update account.
79+
* *\<instance_name>*: The name of your Device Update instance.
80+
* *\<storage_id>*: The resource ID of the storage account where the diagnostics logs will be stored. You can retrieve the resource ID by using the [az storage show](/cli/azure/storage/account#az-storage-account-show) command and querying for the ID value: `az storage account show -n <storage_name> --query id`.
3781

38-
## Configure which log files are collected from your device
82+
```azurecli-interactive
83+
az iot device-update instance update --account <account_name> --instance <instance_name> --set enableDiagnostics=true diagnosticStorageProperties.resourceId=<storage_id>
84+
```
3985

40-
The Device Update agent on a device will collect files from specific file paths on the device when it receives a log upload start signal from the Device Update service. These file paths are defined by a configuration file on the device, located at **/etc/adu/du-diagnostics-config.json** in the reference agent.
86+
---
87+
88+
## Configure log collection
89+
90+
The device update agent refers to a configuration file on the device, located at **/etc/adu/du-diagnostics-config.json** in the reference agent.
91+
92+
### Log collection file paths
4193

42-
Within the configuration file, each log file to be collected and uploaded is represented as a "logComponent" object with componentName and logPath properties. This can be modified as desired.
94+
The Device Update agent on a device will collect files from specific file paths on the device when it receives a log upload start signal from the Device Update service. These file paths are defined in the diagnostics config file.
4395

44-
## Configure max log file size
96+
Within the configuration file, each log file to be collected and uploaded is represented as a `logComponent` object with componentName and logPath properties. This configuration can be modified as desired.
4597

46-
The Device Update agent will only collect log files under a certain file size. This max file size is defined by a configuration file on the device, located at **/etc/adu/du-diagnostics-config.json** in the reference agent.
98+
### Max log file size
99+
100+
The Device Update agent will only collect log files under a certain file size. This max file size is defined in the diagnostics config file.
47101

48102
The relevant parameter "maxKilobytesToUploadPerLogPath" will apply to each logComponent object, and can be modified as desired.
49103

50-
## Create a new log operation within Device Update for IoT Hub.
104+
## Create a log operation
51105

52-
Log operations are a new service-driven action that you can instruct your IoT devices to perform through the Device Update service. For a more detailed explanation of how log operations function, please see the [Device update diagnostics](device-update-diagnostics.md) concept page.
106+
Log operations are a service-driven action that you can instruct your IoT devices to perform through the Device Update service. For a more detailed explanation of how log operations function, see [Device update diagnostics](device-update-diagnostics.md).
53107

54108
1. Navigate to your IoT Hub and select the **Updates** tab under the **Device Management** section of the navigation pane.
55109

@@ -63,7 +117,7 @@ Log operations are a new service-driven action that you can instruct your IoT de
63117

64118
6. Once back on the Diagnostics tab, select **Refresh** until you see your log operation listed in the Operation Table.
65119

66-
7. Once the operation status is **Succeeded** or **Failed**, select the operation name to view its details. An operation will be marked "Succeeded" only if all targeted devices successfully completed the log upload. If some targeted devices succeeded and some failed, the log operation will be marked "Failed." You can use the log operation details blade to see which devices succeeded and which failed.
120+
7. Once the operation status is **Succeeded** or **Failed**, select the operation name to view its details. An operation will be marked "Succeeded" only if all targeted devices successfully completed the log upload. If some targeted devices succeeded and some failed, the log operation will be marked "Failed." You can use the log operation details page to see which devices succeeded and which failed.
67121

68122
8. In the log operation details, you can view the device-specific status and see the log location path. This path corresponds to the virtual directory path within your Azure Blob storage account where the diagnostic logs have been uploaded.
69123

@@ -73,18 +127,16 @@ Log operations are a new service-driven action that you can instruct your IoT de
73127

74128
2. Select **Containers** under the **Data storage** section of the navigation pane.
75129

76-
3. Select the container with the same name as your Device Update instance.
130+
3. Select the container with the same name as your Device Update instance.
77131

78132
4. Use the log location path from the log operation details to navigate to the correct directory containing the logs. By default, the remote log collection feature instructs targeted devices to upload diagnostic logs using the following directory path model: **Blob storage container/Target device ID/Log operation ID/On-device log path**
79133

80-
5. If you haven't modified the diagnostic component of the DU Agent, the device will respond to any log operation by attempting to upload two plaintext log files: the DU Agent diagnostic log ("aduc.log"), and the DO Agent diagnostic log ("do-agent.log"). You can learn more about which log files the DU reference agent collects by reading the [Device update diagnostics](device-update-diagnostics.md) concept page.
134+
5. If you haven't modified the diagnostic component of the DU agent, the device will respond to any log operation by attempting to upload two plaintext log files: the DU agent diagnostic log ("aduc.log"), and the DO agent diagnostic log ("do-agent.log"). You can learn more about which log files the DU reference agent collects by reading the [Device update diagnostics](device-update-diagnostics.md) concept page.
81135

82136
6. You can view the log file's contents by selecting the file name, then selecting the menu element (ellipsis) and clicking **View/edit**. You can also download or delete the log file by selecting the respectively labeled options.
83-
:::image type="content" source="media/device-update-log-collection/blob-storage-log.png" alt-text="Screenshot of log file within Azure Blob storage." lightbox="media/device-update-log-collection/blob-storage-log.png":::
84-
85-
## Next steps
86137

87-
Learn more about Device Update's diagnostic capabilities:
138+
:::image type="content" source="media/device-update-log-collection/blob-storage-log.png" alt-text="Screenshot of log file within Azure Blob storage." lightbox="media/device-update-log-collection/blob-storage-log.png":::
88139

89-
- [Device update diagnostic feature overview](device-update-diagnostics.md)
140+
## Next steps
90141

142+
To learn more about Device Update's diagnostic capabilities, see [Device update diagnostic feature overview](device-update-diagnostics.md)
8.89 KB
Loading
3 Bytes
Loading
-6.01 KB
Loading
-7.88 KB
Loading
-7.73 KB
Loading
-2.74 KB
Loading
-375 Bytes
Loading

0 commit comments

Comments
 (0)