Skip to content

Commit 6d27a78

Browse files
Merge pull request #264486 from dominicbetts/aio-assets-az
AIO: Add CLI asset management commands
2 parents e350e5d + f6611fa commit 6d27a78

File tree

1 file changed

+182
-14
lines changed

1 file changed

+182
-14
lines changed

articles/iot-operations/manage-devices-assets/howto-manage-assets-remotely.md

Lines changed: 182 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Manage asset configurations remotely
3-
description: Use the Azure IoT Operations portal to manage your asset configurations remotely and enable data to flow from your assets to an MQTT broker.
3+
description: Use the Azure IoT Operations portal or the Azure CLI to manage your asset configurations remotely and enable data to flow from your assets to an MQTT broker.
44
author: dominicbetts
55
ms.author: dobett
66
ms.topic: how-to
@@ -21,25 +21,22 @@ _OPC UA servers_ are software applications that communicate with assets. OPC UA
2121

2222
An _asset endpoint_ is a custom resource in your Kubernetes cluster that connects OPC UA servers to OPC UA connector modules. This connection enables an OPC UA connector to access an asset's data points. Without an asset endpoint, data can't flow from an OPC UA server to the Azure IoT OPC UA Broker (preview) instance and Azure IoT MQ (preview) instance. After you configure the custom resources in your cluster, a connection is established to the downstream OPC UA server and the server forwards telemetry to the OPC UA Broker instance.
2323

24-
This article describes how to use the Azure IoT Operations (preview) portal to:
24+
This article describes how to use the Azure IoT Operations (preview) portal and the Azure CLI to:
2525

2626
- Define asset endpoints
2727
- Add assets, and define tags and events.
2828

2929
These assets, tags, and events map inbound data from OPC UA servers to friendly names that you can use in the MQ broker and Azure IoT Data Processor (preview) pipelines.
3030

31-
You can also use the Azure CLI to manage assets and asset endpoints. To learn more, see:
32-
33-
- [az iot ops asset](/cli/azure/iot/ops/asset)
34-
- [az iot ops asset endpoint](/cli/azure/iot/ops/asset/endpoint).
35-
3631
## Prerequisites
3732

3833
To configure an assets endpoint, you need a running instance of Azure IoT Operations.
3934

40-
## Sign in to the Azure IoT Operations portal
35+
## Sign in
4136

42-
Navigate to the [Azure IoT Operations portal](https://iotoperations.azure.com) in your browser and sign in by using your Microsoft Entra ID credentials.
37+
# [Azure IoT Operations portal](#tab/portal)
38+
39+
To sign in to the Azure IoT Operations portal, navigate to the [Azure IoT Operations portal](https://iotoperations.azure.com) in your browser and sign in by using your Microsoft Entra ID credentials.
4340

4441
## Select your cluster
4542

@@ -53,10 +50,22 @@ When you sign in, the portal displays a list of the Azure Arc-enabled Kubernetes
5350
> [!TIP]
5451
> You can use the filter box to search for clusters.
5552
53+
# [Azure CLI](#tab/cli)
54+
55+
Before you use the `az az iot ops asset` commands, sign in to the subscription that contains your Azure IoT Operations deployment:
56+
57+
```azurecli
58+
az login
59+
```
60+
61+
---
62+
5663
## Create an asset endpoint
5764

5865
By default, an Azure IoT Operations deployment includes a built-in OPC PLC simulator. To create an asset endpoint that uses the built-in OPC PLC simulator:
5966

67+
# [Azure IoT Operations portal](#tab/portal)
68+
6069
1. Select **Asset endpoints** and then **Create asset endpoint**:
6170

6271
:::image type="content" source="media/howto-manage-assets-remotely/asset-endpoints.png" alt-text="Screenshot that shows the asset endpoints page in the Azure IoT Operations portal.":::
@@ -75,14 +84,31 @@ By default, an Azure IoT Operations deployment includes a built-in OPC PLC simul
7584

7685
1. To save the definition, select **Create**.
7786

78-
This configuration deploys a new module called `opc-ua-connector-0` to the cluster. After you define an asset, an OPC UA connector pod discovers it. The pod uses the asset endpoint that you specify in the asset definition to connect to an OPC UA server.
87+
# [Azure CLI](#tab/cli)
88+
89+
Run the following command:
90+
91+
```azurecli
92+
az iot ops asset endpoint create --name opc-ua-connector-0 --target-address opc.tcp://opcplc-000000:50000 -g {your resource group name} --cluster {your cluster name}
93+
```
94+
95+
> [!TIP]
96+
> Use `az connectedk8s list` to list the clusters you have access to.
97+
98+
To learn more, see [az iot ops asset endpoint](/cli/azure/iot/ops/asset/endpoint).
99+
100+
---
101+
102+
This configuration deploys a new `assetendpointprofile` resource called `opc-ua-connector-0` to the cluster. After you define an asset, an OPC UA connector pod discovers it. The pod uses the asset endpoint that you specify in the asset definition to connect to an OPC UA server.
79103

80104
When the OPC PLC simulator is running, data flows from the simulator, to the connector, to the OPC UA broker, and finally to the MQ broker.
81105

82106
### Configure an asset endpoint to use a username and password
83107

84108
The previous example uses the `Anonymous` authentication mode. This mode doesn't require a username or password.
85109

110+
# [Azure IoT Operations portal](#tab/portal)
111+
86112
To use the `UsernamePassword` authentication mode, complete the following steps:
87113

88114
1. Follow the steps in [Configure OPC UA user authentication with username and password](howto-configure-opcua-authentication-options.md#configure-opc-ua-user-authentication-with-username-and-password) to add secrets for username and password in Azure Key Vault, and project them into Kubernetes cluster.
@@ -93,18 +119,50 @@ To use the `UsernamePassword` authentication mode, complete the following steps:
93119
| Username reference | `aio-opc-ua-broker-user-authentication/username` |
94120
| Password reference | `aio-opc-ua-broker-user-authentication/password` |
95121

122+
# [Azure CLI](#tab/cli)
123+
124+
To use the `UsernamePassword` authentication mode, complete the following steps:
125+
126+
1. Follow the steps in [Configure OPC UA user authentication with username and password](howto-configure-opcua-authentication-options.md#configure-opc-ua-user-authentication-with-username-and-password) to add secrets for username and password in Azure Key Vault, and project them into Kubernetes cluster.
127+
128+
1. Use a command like the following example to create your asset endpoint:
129+
130+
```azurecli
131+
az iot ops asset endpoint create --name opc-ua-connector-0 --target-address opc.tcp://opcplc-000000:50000 -g {your resource group name} --cluster {your cluster name} --username-ref "aio-opc-ua-broker-user-authentication/username" --password-ref "aio-opc-ua-broker-user-authentication/password"
132+
```
133+
134+
---
135+
96136
### Configure an asset endpoint to use a transport authentication certificate
97137
98138
To configure the asset endpoint to use a transport authentication certificate, complete the following steps:
99139
140+
# [Azure IoT Operations portal](#tab/portal)
141+
100142
1. Follow the steps in [Configure OPC UA transport authentication](howto-configure-opcua-authentication-options.md#configure-opc-ua-transport-authentication) to add a transport certificate and private key to Azure Key Vault, and project them into Kubernetes cluster.
101143
2. In Azure IoT Operations portal, select **Use transport authentication certificate** for the **Transport authentication** field and enter the certificate thumbprint.
102144
145+
# [Azure CLI](#tab/cli)
146+
147+
1. Follow the steps in [Configure OPC UA transport authentication](howto-configure-opcua-authentication-options.md#configure-opc-ua-transport-authentication) to add a transport certificate and private key to Azure Key Vault, and project them into Kubernetes cluster.
148+
149+
1. Use a command like the following example to create your asset endpoint:
150+
151+
```azurecli
152+
az iot ops asset endpoint create --name opc-ua-connector-0 --target-address opc.tcp://opcplc-000000:50000 -g {your resource group name} --cluster {your cluster name} --username-ref "aio-opc-ua-broker-user-authentication/username" --password-ref "aio-opc-ua-broker-user-authentication/password" --cert secret=aio-opc-ua-broker-client-certificate thumbprint=000000000000000000 password=aio-opc-ua-broker-client-certificate-password
153+
```
154+
155+
To learn more, see [az iot ops asset](/cli/azure/iot/ops/asset).
156+
157+
---
158+
103159
## Add an asset, tags, and events
104160
161+
# [Azure IoT Operations portal](#tab/portal)
162+
105163
To add an asset in the Azure IoT Operations portal:
106164
107-
1. Select the **Assets** tab. If you haven't created any assets yet, you see the following screen:
165+
1. Select the **Assets** tab. Before you create any assets, you see the following screen:
108166
109167
:::image type="content" source="media/howto-manage-assets-remotely/create-asset-empty.png" alt-text="Screenshot that shows an empty Assets tab in the Azure IoT Operations portal.":::
110168
@@ -166,7 +224,7 @@ Now you can define the tags associated with the asset. To add OPC UA tags:
166224
167225
- **Sampling interval (milliseconds)**: The sampling interval indicates the fastest rate at which the OPC UA Server should sample its underlying source for data changes.
168226
- **Publishing interval (milliseconds)**: The rate at which OPC UA Server should publish data.
169-
- **Queue size**: The depth of the queue to hold the sampling data before it's published.
227+
- **Queue size**: The depth of the queue to hold the sampling data before publishing it.
170228
171229
### Add tags in bulk to an asset
172230
@@ -199,8 +257,38 @@ You can import up to 1000 OPC UA tags at a time from a CSV file:
199257
> [!TIP]
200258
> You can use the filter box to search for tags.
201259
260+
# [Azure CLI](#tab/cli)
261+
262+
Use the following command to add a "thermostat" asset by using the Azure CLI. The command adds two tags to the asset by using the `--data` parameter:
263+
264+
```azurecli
265+
az iot ops asset create --name thermostat -g {your resource group name} --cluster {your cluster name} --endpoint opc-ua-connector-0 --description 'A simulated thermostat asset' --data data_source='ns=3;s=FastUInt10', name=temperature --data data_source='ns=3;s=FastUInt100', name='Tag 10'
266+
```
267+
268+
When you create an asset by using the Azure CLI, you can define:
269+
270+
- Multiple tags by using the `--data` parameter multiple times.
271+
- Multiple events by using the `--event` parameter multiple times.
272+
- Optional information for the asset such as:
273+
- Manufacturer
274+
- Manufacturer URI
275+
- Model
276+
- Product code
277+
- Hardware version
278+
- Software version
279+
- Serial number
280+
- Documentation URI
281+
- Default values for sampling interval, publishing interval, and queue size.
282+
- Tag specific values for sampling interval, publishing interval, and queue size.
283+
- Event specific values for sampling publishing interval, and queue size.
284+
- The observability mode for each tag and event
285+
286+
---
287+
202288
### Add individual events to an asset
203289

290+
# [Azure IoT Operations portal](#tab/portal)
291+
204292
Now you can define the events associated with the asset. To add OPC UA events:
205293

206294
1. Select **Add > Add event**.
@@ -222,7 +310,7 @@ Now you can define the events associated with the asset. To add OPC UA events:
222310
1. Select **Manage default settings** to configure default event settings for the asset. These settings apply to all the OPC UA events that belong to the asset. You can override these settings for each event that you add. Default event settings include:
223311

224312
- **Publishing interval (milliseconds)**: The rate at which OPC UA Server should publish data.
225-
- **Queue size**: The depth of the queue to hold the sampling data before it's published.
313+
- **Queue size**: The depth of the queue to hold the sampling data before publishing it.
226314

227315
### Add events in bulk to an asset
228316

@@ -241,8 +329,27 @@ Review your asset and OPC UA tag and event details and make any adjustments you
241329

242330
:::image type="content" source="media/howto-manage-assets-remotely/review-asset.png" alt-text="A screenshot that shows how to review your asset, tags, and events in the Azure IoT Operations portal.":::
243331

332+
# [Azure CLI](#tab/cli)
333+
334+
When you create an asset by using the Azure CLI, you can define multiple events by using the `--event` parameter multiple times. The syntax for the `--event` parameter is similar to the `--data` parameter:
335+
336+
```azurecli
337+
az iot ops asset create --name thermostat -g {your resource group name} --cluster {your cluster name} --endpoint opc-ua-connector-0 --description 'A simulated thermostat asset' --event event_notifier='ns=3;s=FastUInt12', name=warning
338+
```
339+
340+
For each event that you define, you can specify the:
341+
342+
- Event notifier. This value is the event notifier from the OPC UA server.
343+
- Event name. This value is the friendly name that you want to use for the event. If you don't specify an event name, the event notifier is used as the event name.
344+
- Observability mode.
345+
- Queue size.
346+
347+
---
348+
244349
## Update an asset
245350

351+
# [Azure IoT Operations portal](#tab/portal)
352+
246353
Find and select the asset you created previously. Use the **Properties**, **Tags**, and **Events** tabs to make any changes:
247354

248355
:::image type="content" source="media/howto-manage-assets-remotely/asset-update-property-save.png" alt-text="A screenshot that shows how to update an existing asset in the Azure IoT Operations portal.":::
@@ -261,19 +368,80 @@ You can also add, update, and delete events and properties in the same way.
261368

262369
When you're finished making changes, select **Save** to save your changes.
263370

371+
# [Azure CLI](#tab/cli)
372+
373+
To list your assets, use the following command:
374+
375+
```azurecli
376+
az iot ops asset query -g {your resource group name}
377+
```
378+
379+
> [!TIP]
380+
> You can refine the query command to search for assets that match specific criteria. For example, you can search for assets by manufacturer.
381+
382+
To view the details of the thermostat asset, use the following command:
383+
384+
```azurecli
385+
az iot ops asset show --name thermostat -g {your resource group}
386+
```
387+
388+
To update an asset, use the `az iot ops asset update` command. For example, to update the asset's description, use a command like the following example:
389+
390+
```azurecli
391+
az iot ops asset update --name thermostat --description 'A simulated thermostat asset' -g {your resource group}
392+
```
393+
394+
To list the thermostat asset's tags, use the following command:
395+
396+
```azurecli
397+
az iot ops asset data-point list --asset thermostat -g {your resource group}
398+
```
399+
400+
To list the thermostat asset's events, use the following command:
401+
402+
```azurecli
403+
az iot ops asset event list --asset thermostat -g {your resource group}
404+
```
405+
406+
To add a new tag to the thermostat asset, use a command like the following example:
407+
408+
```azurecli
409+
az iot ops asset data-point add --asset thermostat -g {your resource group} --data-source 'ns=3;s=FastUInt1002' --name 'humidity'
410+
```
411+
412+
To delete a tag, use the `az iot ops asset data-point remove` command.
413+
414+
You can manage an asset's events by using the `az iot ops asset event` commands.
415+
416+
---
417+
264418
## Delete an asset
265419

420+
# [Azure IoT Operations portal](#tab/portal)
421+
266422
To delete an asset, select the asset you want to delete. On the **Asset** details page, select **Delete**. Confirm your changes to delete the asset:
267423

268424
:::image type="content" source="media/howto-manage-assets-remotely/asset-delete.png" alt-text="A screenshot that shows how to delete an asset from the Azure IoT Operations portal.":::
269425

426+
# [Azure CLI](#tab/cli)
427+
428+
To delete an asset, use a command that looks like the following example:
429+
430+
```azurecli
431+
az iot ops asset delete --name thermostat -g {your resource group name}
432+
```
433+
434+
---
435+
270436
## Notifications
271437

272-
Whenever you make a change to asset, you see a notification in the Azure IoT Operations portal that reports the status of the operation:
438+
Whenever you make a change to asset in the Azure IoT Operations portal, you see a notification that reports the status of the operation:
273439

274440
:::image type="content" source="media/howto-manage-assets-remotely/portal-notifications.png" alt-text="A screenshot that shows the notifications in the Azure IoT Operations portal.":::
275441

276442
## Related content
277443

278444
- [Azure OPC UA Broker overview](overview-opcua-broker.md)
279445
- [Azure IoT Akri overview](overview-akri.md)
446+
- [az iot ops asset](/cli/azure/iot/ops/asset)
447+
- [az iot ops asset endpoint](/cli/azure/iot/ops/asset/endpoint)

0 commit comments

Comments
 (0)