Skip to content

Commit a05ed93

Browse files
committed
Add discovery how to
1 parent 9c19b9d commit a05ed93

File tree

7 files changed

+43
-111
lines changed

7 files changed

+43
-111
lines changed
Lines changed: 43 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,152 +1,84 @@
11
---
2-
title: Discover OPC UA data sources using the Akri services
3-
description: How to discover and configure OPC UA data sources at the edge automatically by using the Akri services
2+
title: Automatically discover OPC UA assets (preview)
3+
description: How to automatically discover and configure OPC UA assets at the edge
44
author: dominicbetts
5-
ms.author: dobett
65
ms.subservice: azure-akri
6+
ms.author: dobett
77
ms.topic: how-to
8-
ms.date: 05/15/2024
8+
ms.date: 04/02/2025
99

10-
# CustomerIntent: As an industrial edge IT or operations user, I want to discover and create OPC UA data sources in my industrial edge environment so that I can reduce manual configuration overhead.
10+
# CustomerIntent: As an industrial edge IT or operations user, I want to discover and create OPC UA assets in my industrial edge environment so that I can reduce manual configuration overhead.
1111
---
1212

13-
# Discover OPC UA data sources using the Akri services
14-
15-
In this article, you learn how to discover OPC UA data sources automatically. After you deploy Azure IoT Operations Preview, you configure the Akri services to discover OPC UA data sources at the edge. The Akri services create custom resources in your Kubernetes cluster that represent the data sources it discovers. The ability to discover OPC UA data sources removes the need to [manually configure them by using the operations experience web UI](howto-manage-assets-remotely.md).
16-
17-
> [!IMPORTANT]
18-
> Currently, you can't use Azure Device Registry to manage the assets that the Akri services discover and create.
13+
# Automatically discover and configure OPC UA assets (preview)
1914

20-
The Akri services enable you to detect and create assets in the address space of an OPC UA server. The OPC UA asset detection generates `AssetType` and `Asset` custom resources for [OPC UA Device Integration (DI) specification](https://reference.opcfoundation.org/DI/v104/docs/) compliant assets.
15+
In this article, you learn how to automatically discover and configure OPC UA assets connected to your Azure IoT Operations deployment. The automatic discovery process starts when you add an asset endpoint with the **Enable discovery** option selected.
2116

2217
## Prerequisites
2318

24-
- Install Azure IoT Operations Preview. To install Azure IoT Operations for demonstration and exploration purposes, see [Quickstart: Run Azure IoT Operations Preview in Github Codespaces with K3s](../get-started-end-to-end-sample/quickstart-deploy.md).
25-
- Verify that the Akri services pods are properly configured by running the following command:
19+
A deployed instance of Azure IoT Operations. If you don't already have an instance, see [Quickstart: Run Azure IoT Operations in GitHub Codespaces with K3s](../get-started-end-to-end-sample/quickstart-deploy.md).
2620

27-
```bash
28-
kubectl get pods -n azure-iot-operations
29-
```
21+
## Create an asset endpoint
3022

31-
The output includes a line that shows the Akri agent and discovery pods are running:
23+
To create an asset endpoint with discovery enabled:
3224

33-
```output
34-
NAME READY STATUS RESTARTS AGE
35-
aio-akri-agent-daemonset-hwpc7 1/1 Running 0 17mk0s
36-
aio-opc-asset-discovery-wzlnj 1/1 Running 0 8m28s
37-
```
25+
1. Go to your Azure IoT Operations instance in the operations experience web UI.
3826

39-
## Configure the OPC UA discovery handler
27+
1. Add a new asset endpoint and select the **Enable discovery** option:
4028

41-
To configure the OPC UA discovery handler for asset detection, create a YAML configuration file that contains the values described in this section:
29+
:::image type="content" source="media/howto-autodetect-opcua-assets-using-akri/enable-auto-discover.png" alt-text="Create an asset endpoint with discovery enabled.":::
4230

43-
| Name | Mandatory | Datatype | Default | Comment |
44-
| ---- | --------- | -------- | ------- | ------- |
45-
| `EndpointUrl` | true | String | null | The OPC UA endpoint URL to use for asset discovery |
46-
| `AutoAcceptUntrustedCertificates` | true ¹ | Boolean | false | Should the client autoaccept untrusted certificates? A certificate can only be autoaccepted as trusted if no nonsuppressible errors occurred during chain validation. For example, a certificate with incomplete chain isn't accepted. |
47-
| `UseSecurity` | true ¹ | Boolean | true | Should the client use a secure connection? |
48-
| `UserName` | false | String | null | The username for user authentication. ² |
49-
| `Password` | false | String | null | The password for user authentication. ² |
31+
1. Select **Create** to create the asset endpoint.
5032

51-
¹ The current version of the discovery handler only supports `UseSecurity=false` and requires `autoAcceptUntrustedCertificates=true`.
52-
² A temporary implementation until the Akri services can pass Kubernetes secrets.
33+
## Review the discovered assets
5334

54-
The following example demonstrates discovery of an OPC PLC server. You can add the asset parameters for multiple OPC PLC servers.
35+
Azure IoT Operations uses the asset endpoint to connect to the OPC UA server and scan for assets. To view the discovered assets:
5536

56-
1. To create the YAML configuration file, copy and paste the following content into a new file, and save it as `opcua-configuration.yaml`:
37+
1. Go to the **Discovery** page for your instance in the operations experience:
5738

58-
If you're using the simulated PLC server that was deployed with the Azure IoT Operations Quickstart, you don't need to change the `endpointUrl`. If you have your own OPC UA servers running or are using the simulated PLC servers deployed on Azure, add in your endpoint URL accordingly. Discovery endpoint URLs look like `opc.tcp://<FQDN>:50000/`. To find the FQDNs of your OPC PLC servers, go to your deployment in the Azure portal. For each server, copy and paste the **FQDN** value into your endpoint URLs.
39+
:::image type="content" source="media/howto-autodetect-opcua-assets-using-akri/discovered-assets-list.png" alt-text="View discovered assets.":::
5940

60-
```yaml
61-
apiVersion: akri.sh/v0
62-
kind: Configuration
63-
metadata:
64-
name: aio-akri-opcua-asset
65-
spec:
66-
discoveryHandler:
67-
name: opcua-asset
68-
discoveryDetails: "opcuaDiscoveryMethod:\n - asset:\n endpointUrl: \" opc.tcp://opcplc-000000:50000\"\n useSecurity: false\n autoAcceptUntrustedCertificates: true\n"
69-
brokerProperties: {}
70-
capacity: 1
71-
```
41+
1. You can filter the list by the asset endpoint name, or by keyword. The list shows the discovered assets and their status.
7242

73-
1. To apply the configuration, run the following command:
43+
## Import an asset from a discovered asset
7444

75-
```bash
76-
kubectl apply -f opcua-configuration.yaml -n azure-iot-operations
77-
```
45+
From the list of discovered assets, you can import an asset into your Azure IoT Operations instance. To import an asset:
7846

79-
> [!TIP]
80-
> In a default Azure IoT Operations deployment, the OPC UA discovery handler is already configured to discover the simulated PLC server. If you want to discover assets connected to additional OPC UA servers, you can add them to the configuration file.
81-
82-
## Verify the configuration
47+
1. Select the asset you want to import from the list of discovered assets. Then select **+ Import and create asset**.
8348

84-
To confirm that the asset discovery container is configured and running:
49+
1. The site takes you to the **Add asset details** page, where you can review the asset details and make any changes. The asset name is automatically populated with the name of the discovered asset, but you can override the name on this page:
8550

86-
1. Use the following command to check the pod logs:
51+
:::image type="content" source="media/howto-autodetect-opcua-assets-using-akri/add-asset-details.png" alt-text="An asset from a discovered asset.":::
8752

88-
```bash
89-
kubectl logs <insert aio-opc-asset-discovery pod name> -n azure-iot-operations
90-
```
53+
1. Step through the rest of the **Create asset** pages and make any changes you want to the imported details, tags, and events:
9154

92-
A log from the `aio-opc-asset-discovery` pod indicates after a few seconds that the discovery handler registered itself with the Akri services:
55+
:::image type="content" source="media/howto-autodetect-opcua-assets-using-akri/add-imported-tags.png" alt-text="Modify the tags of an imported asset.":::
9356

94-
```2024-08-01T15:04:12.874Z aio-opc-asset-discovery-4nsgs - Akri OPC UA Asset Discovery (1.0.0-preview-20240708+702c5cafeca2ea49fec3fb4dc6645dd0d89016ee) is starting with the process id: 1
95-
2024-08-01T15:04:12.948Z aio-opc-asset-discovery-4nsgs - OPC UA SDK 1.5.374.70 from 07/20/2024 07:37:16
96-
2024-08-01T15:04:12.973Z aio-opc-asset-discovery-4nsgs - OPC UA SDK informational version: 1.5.374.70+1ee3beb87993019de4968597d17cb54d5a4dc3c8
97-
2024-08-01T15:04:12.976Z aio-opc-asset-discovery-4nsgs - Akri agent registration enabled: True
98-
2024-08-01T15:04:13.475Z aio-opc-asset-discovery-4nsgs - Hosting starting
99-
2024-08-01T15:04:13.547Z aio-opc-asset-discovery-4nsgs - Overriding HTTP_PORTS '8080' and HTTPS_PORTS ''. Binding to values defined by URLS instead 'http://+:8080'.
100-
2024-08-01T15:04:13.774Z aio-opc-asset-discovery-4nsgs - Now listening on: http://:8080
101-
2024-08-01T15:04:13.774Z aio-opc-asset-discovery-4nsgs - Application started. Press Ctrl+C to shut down.
102-
2024-08-01T15:04:13.774Z aio-opc-asset-discovery-4nsgs - Hosting environment: Production
103-
2024-08-01T15:04:13.774Z aio-opc-asset-discovery-4nsgs - Content root path: /app
104-
2024-08-01T15:04:13.774Z aio-opc-asset-discovery-4nsgs - Hosting started
105-
2024-08-01T15:04:13.881Z aio-opc-asset-discovery-4nsgs - Registering with Agent as HTTP endpoint using own IP from the environment variable POD_IP: 10.42.0.245
106-
2024-08-01T15:04:14.875Z aio-opc-asset-discovery-4nsgs - Registered with the Akri agent with name opcua-asset for http://10.42.0.245:8080 with type Network and shared True
107-
2024-08-01T15:04:14.877Z aio-opc-asset-discovery-4nsgs - Successfully re-registered OPC UA Asset Discovery Handler with the Akri agent
108-
2024-08-01T15:04:14.877Z aio-opc-asset-discovery-4nsgs - Press CTRL+C to exit
109-
```
57+
1. The imported asset is created in your Azure IoT Operations instance. You can view the asset in the **Assets** page of the operations experience:
11058

111-
After about a minute, the Akri services issue the first discovery request based on the configuration:
59+
:::image type="content" source="media/howto-autodetect-opcua-assets-using-akri/provisioned-asset.png" alt-text="View the imported asset.":::
11260

113-
```output
114-
2024-08-01T15:04:15.280Z aio-opc-asset-discovery-4nsgs [opcuabroker@311 SpanId:6d3db9751eebfadc, TraceId:e5594cbaf3993749e92b45c88c493377, ParentId:0000000000000000 ConnectionId:0HN5I7CQJPJL0 RequestPath:/v0.DiscoveryHandler/Discover RequestId:0HN5I7CQJPJL0:00000001] - Reading message.
115-
2024-08-01T15:04:15.477Z aio-opc-asset-discovery-4nsgs [opcuabroker@311 SpanId:6d3db9751eebfadc, TraceId:e5594cbaf3993749e92b45c88c493377, ParentId:0000000000000000 ConnectionId:0HN5I7CQJPJL0 RequestPath:/v0.DiscoveryHandler/Discover RequestId:0HN5I7CQJPJL0:00000001] - Received discovery request from ipv6:[::ffff:10.42.0.241]:48638
116-
2024-08-01T15:04:15.875Z aio-opc-asset-discovery-4nsgs [opcuabroker@311 SpanId:6d3db9751eebfadc, TraceId:e5594cbaf3993749e92b45c88c493377, ParentId:0000000000000000 ConnectionId:0HN5I7CQJPJL0 RequestPath:/v0.DiscoveryHandler/Discover RequestId:0HN5I7CQJPJL0:00000001] - Start asset discovery
117-
2024-08-01T15:04:15.882Z aio-opc-asset-discovery-4nsgs [opcuabroker@311 SpanId:6d3db9751eebfadc, TraceId:e5594cbaf3993749e92b45c88c493377, ParentId:0000000000000000 ConnectionId:0HN5I7CQJPJL0 RequestPath:/v0.DiscoveryHandler/Discover RequestId:0HN5I7CQJPJL0:00000001] - Discovering OPC UA opc.tcp://opcplc-000000:50000 using Asset Discovery
118-
2024-08-01T15:04:15.882Z aio-opc-asset-discovery-4nsgs [opcuabroker@311 SpanId:6d3db9751eebfadc, TraceId:e5594cbaf3993749e92b45c88c493377, ParentId:0000000000000000 ConnectionId:0HN5I7CQJPJL0 RequestPath:/v0.DiscoveryHandler/Discover RequestId:0HN5I7CQJPJL0:00000001] - Selected AutoAcceptUntrustedCertificates mode: False
119-
```
61+
To learn more about managing asset configurations, see [Manage asset configurations remotely](howto-manage-assets-remotely.md).
12062

121-
After the discovery is complete, the discovery handler sends the result back to the Akri services to create an Akri instance custom resource with asset information and observable variables. The discovery handler repeats the discovery every 10 minutes to detect any changes on the server.
63+
## Review the asset definitions in the Azure portal (optional)
12264

123-
1. To view the discovered Akri instances, run the following command:
65+
Both the discovered asset and the imported asset are visible in your resource group in the Azure portal:
12466

125-
```bash
126-
kubectl get akrii -n azure-iot-operations
127-
```
67+
:::image type="content" source="media/howto-autodetect-opcua-assets-using-akri/portal-assets.png" alt-text="View the discovered and imported asset in the Azure portal.":::
12868

129-
The output from the previous command looks like the following example. You might need to wait for a few seconds for the Akri instance to be created:
69+
## Review the custom resource definitions in your cluster (optional)
13070

131-
```output
132-
NAME CONFIG SHARED NODES AGE
133-
akri-opcua-asset-dbdef0 akri-opcua-asset true ["k3d-k3s-default-server-0"] 24h
134-
```
71+
To review the discovered assets in your cluster, you can use the `kubectl` command line tool:
13572

136-
The connector for OPC UA supervisor watches for new Akri instance custom resources of type `opc-ua-asset`, and generates the initial asset types and asset custom resources for them. You can modify asset custom resources by adding settings such as extended publishing for more data points, or connector for OPC UA observability settings.
73+
```console
74+
kubectl get discoveredassets -n azure-iot-operations
75+
```
13776

138-
1. To confirm that the Akri instance properly connected to the connector for OPC UA, run the following command. Replace the placeholder with the name of the Akri instance that was included in the output of the previous command:
77+
To view the details of a discovered asset, use the following command:
13978

140-
```bash
141-
kubectl get akrii <AKRI_INSTANCE_NAME> -n azure-iot-operations -o json
142-
```
79+
```console
80+
kubectl describe discoveredasset <name> -n azure-iot-operations
81+
```
14382

144-
The command output includes a section that looks like the following example. The snippet shows the Akri instance `brokerProperties` values and confirms that the connector for OPC UA is connected.
145-
146-
```json
147-
"spec": {
148-
149-
"brokerProperties": {
150-
"ApplicationUri": "Boiler #2",
151-
"AssetEndpointProfile": "{\"spec\":{\"uuid\":\"opc-ua-broker-opcplc-000000-azure-iot-operation\"……
152-
```
83+
> [!TIP]
84+
> The previous commands assume that you installed your Azure IoT Operations instance in the default `azure-iot-operations` namespace. If you installed it in a different namespace, replace `azure-iot-operations` with the name of your namespace.
Loading
Loading
Loading
Loading
48.9 KB
Loading
Loading

0 commit comments

Comments
 (0)