Skip to content

Commit 2b294a2

Browse files
clarify usage of OPC PLC Server
1 parent 7db8ca4 commit 2b294a2

File tree

2 files changed

+62
-63
lines changed

2 files changed

+62
-63
lines changed

articles/iot-operations/get-started/quickstart-add-assets.md

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Complete [Quickstart: Deploy Azure IoT Operations Preview to an Arc-enabled Kube
2929

3030
To sign in to the Azure IoT Operations portal, you need a work or school account in the tenant where you deployed Azure IoT Operations. If you're currently using a Microsoft account (MSA), you need to create a Microsoft Entra ID with at least contributor permissions for the resource group that contains your **Kubernetes - Azure Arc** instance. To learn more, see [Known Issues > Create Entra account](../troubleshoot/known-issues.md#azure-iot-operations-preview-portal).
3131

32+
For this quickstart, we use the **OPC PLC simulator** as our OPC UA Server endpoint. Follow [How to configure an OPC PLC simulator to work with Azure IoT OPC UA Broker](../manage-devices-assets/howto-configure-opc-plc-simulator.md) to make sure that OPC PLC is properly installed and configured before you begin.
33+
3234
## What problem will we solve?
3335

3436
The data that OPC UA servers expose can have a complex structure and can be difficult to understand. Azure IoT Operations provides a way to model OPC UA assets as tags, events, and properties. This modeling makes it easier to understand the data and to use it in downstream processes such as the MQ broker and Azure IoT Data Processor Preview pipelines.
@@ -84,40 +86,6 @@ To add an asset endpoint:
8486

8587
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.
8688

87-
The following step lowers the security level for the OPC PLC so that it accepts connections from any client without an explicit peer certificate trust operation. To enable the asset endpoint to use an untrusted certificate:
88-
89-
> [!CAUTION]
90-
> Don't use untrusted certificates in production environments. To learn more, see [Configure an OPC PLC simulator](../manage-devices-assets/howto-configure-opc-plc-simulator.md).
91-
92-
1. Run the following command to enable the use of an untrusted certificate. Replace the two placeholders with your cluster name and resource group name:
93-
94-
```azurecli
95-
az k8s-extension update \
96-
--version 0.3.0-preview \
97-
--name opc-ua-broker \
98-
--release-train preview \
99-
--cluster-name <cluster-name> \
100-
--resource-group <azure-resource-group> \
101-
--cluster-type connectedClusters \
102-
--auto-upgrade-minor-version false \
103-
--config opcPlcSimulation.deploy=true \
104-
--config opcPlcSimulation.autoAcceptUntrustedCertificates=true
105-
```
106-
107-
1. To enable the configuration change to take effect immediately, first find the name of your `aio-opc-supervisor` pod by using the following command:
108-
109-
```console
110-
kubectl get pods -n azure-iot-operations
111-
```
112-
113-
The name of your pod looks like `aio-opc-supervisor-956fbb649-k9ppr`.
114-
115-
1. Restart the `aio-opc-supervisor` pod by using a command that looks like the following example. Use the `aio-opc-supervisor` pod name from the previous step:
116-
117-
```console
118-
kubectl delete pod aio-opc-supervisor-956fbb649-k9ppr -n azure-iot-operations
119-
```
120-
12189
## Manage your assets
12290

12391
After you select your cluster in Azure IoT Operations portal, you see the available list of assets on the **Assets** page. If there are no assets yet, this list is empty:
@@ -204,7 +172,7 @@ The sample tags you added in the previous quickstart generate messages from your
204172

205173
```json
206174
{
207-
"Timestamp": "2024-03-08T00:54:58.6572007Z",
175+
"Timestamp": "2024-03-08T00:54:58.6572007Z",
208176
"MessageType": "ua-deltaframe",
209177
"payload": {
210178
"temperature": {
@@ -261,7 +229,7 @@ kubectl get akrii -n azure-iot-operations
261229

262230
It might take a few minutes for the instance to show up.
263231

264-
The output from the previous command looks like the following example.
232+
The output from the previous command looks like the following example.
265233

266234
```console
267235
NAMESPACE NAME CONFIG SHARED NODES AGE
@@ -270,7 +238,7 @@ azure-iot-operations akri-opcua-asset-dbdef0 akri-opcua-asset true ["d
270238

271239
Now you can use these resources in the local cluster namespace.
272240

273-
To confirm that Akri connected to the OPC UA Broker, copy and paste the name of the Akri instance from the previous step into the following command:
241+
To confirm that Akri connected to the OPC UA Broker, copy and paste the name of the Akri instance from the previous step into the following command:
274242

275243
```bash
276244
kubectl get akrii <AKRI_INSTANCE_NAME> -n azure-iot-operations -o json
@@ -283,7 +251,7 @@ The command output looks like the following example. This example output shows t
283251

284252
"brokerProperties": {
285253
"ApplicationUri": "Boiler #2",
286-
"AssetEndpointProfile": "{\"spec\":{\"uuid\":\"opc-ua-broker-opcplc-000000-azure-iot-operation\"……
254+
"AssetEndpointProfile": "{\"spec\":{\"uuid\":\"opc-ua-broker-opcplc-000000-azure-iot-operation\"……
287255
```
288256

289257
## How did we solve the problem?

articles/iot-operations/manage-devices-assets/howto-configure-opc-plc-simulator.md

Lines changed: 56 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ Azure IoT Operations installed. For more information, see [Quickstart: Deploy Az
2222

2323
## Deploy the OPC PLC simulator
2424

25-
This section shows how to deploy the OPC PLC simulator.
25+
This section shows how to deploy the OPC PLC simulator.
26+
27+
The following step lowers the security level for the OPC PLC so that it accepts connections from AzureIot OPC UA Broker or any client without an explicit peer certificate trust operation.
2628

2729
> [!IMPORTANT]
2830
> Don't use the following example in production, use it for simulation and test purposes only. The example lowers the security level for the OPC PLC so that it accepts connections from any client without an explicit peer certificate trust operation.
@@ -44,27 +46,51 @@ az k8s-extension update \
4446

4547
The OPC PLC OPC UA server should run in the same deployment as a separate pod.
4648

47-
## Get the certificate of the OPC PLC simulator
48-
The application instance certificate of the OPC PLC is a self-signed certificate managed by cert-manager and stored in the `secret aio-opc-ua-opcplc-default-application-cert-000000` kubernetes secret.
49-
50-
To get the certificate, run the following commands on your cluster:
51-
52-
```bash
53-
# extract the public key of the opc plc from the kubernetes secret
54-
kubectl -n azure-iot-operations get secret aio-opc-ua-opcplc-default-application-cert-000000 -o jsonpath='{.data.tls\.crt}' | base64 -d > opcplc.crt
55-
56-
# optionally transform the certificate in *.der format
57-
openssl x509 -outform der -in opcplc.crt -out opcplc.der
58-
```
59-
60-
## Configure OPC UA mutual trust
61-
The next step in OPC UA authentication is to configure mutual trust. In OPC UA communication, the OPC UA client and server authenticate each other.
62-
63-
To complete this configuration, follow the steps to [configure mutual trust](howto-configure-opcua-certificates-infrastructure.md#how-to-handle-the-opc-ua-trusted-certificates-list). Use the certificate file you extracted in the previous section.
49+
## Configure OPC UA mutual trust between Azure Iot OPC UA Broker Preview and the OPC PLC
6450

65-
For simplicity, on the OPC PLC you don't need to do a mutual trust action. Mutual trust is configured with `autoAcceptUntrustedCertificates`, which accepts connections from any OPC UA client.
51+
The application instance certificate of the OPC PLC is a self-signed certificate managed by cert-manager and stored in the `secret aio-opc-ua-opcplc-default-application-cert-000000` kubernetes secret.
6652

67-
## Optionally configure for no authentication
53+
1. Get the certificate, run the following commands on your cluster, and push it to Azure Key Vault.
54+
55+
```bash
56+
kubectl -n azure-iot-operations get secret aio-opc-ua-opcplc-default-application-cert-000000 -o jsonpath='{.data.tls\.crt}' | \
57+
xargs -I {} \
58+
az keyvault secret set \
59+
--name "opcplc-crt" \
60+
--vault-name <azure-key-vault-name> \
61+
--value {} \
62+
--encoding base64 \
63+
--content-type application/x-pem-file
64+
```
65+
66+
2. Configure the secret provider class (SPC) `aio-opc-ua-broker-trust-list` custom resource (CR) in the connected cluster. Use a K8s client such as kubectl to configure the secret `opcplc.crt` in the SPC object array in the connected cluster.
67+
68+
```yml
69+
apiVersion: secrets-store.csi.x-k8s.io/v1
70+
kind: SecretProviderClass
71+
metadata:
72+
name: aio-opc-ua-broker-trust-list
73+
namespace: azure-iot-operations
74+
spec:
75+
provider: azure
76+
parameters:
77+
usePodIdentity: 'false'
78+
keyvaultName: <azure-key-vault-name>
79+
tenantId: <azure-tenant-id>
80+
objects: |
81+
array:
82+
- |
83+
objectName: opcplc-crt
84+
objectType: secret
85+
objectAlias: opcplc.crt
86+
objectEncoding: hex
87+
```
88+
89+
The projection of the Azure Key Vault secrets and certificates into the cluster takes some time depending on the configured polling interval.
90+
91+
Now, the Azure IoT OPC UA Broker the trust relationship with OPC PLC should be established and you can proceed to create an `Asset Endpoint Profile` to connect to your OPC PLC simulation server.
92+
93+
## Optionally configure your `Asset Endpoint Profile` without mutual trust established
6894

6995
You can optionally configure an asset endpoint profile for the OPC PLC to run without mutual trust established. If you understand the risks, you can turn off authentication for testing purposes.
7096

@@ -73,14 +99,19 @@ You can optionally configure an asset endpoint profile for the OPC PLC to run wi
7399
74100
To allow your asset endpoint profile to connect to any OPC PLC server without establishing mutual trust, use the `additionalConfiguration` setting to change the `AssetEndpointProfile` for OPC UA.
75101
76-
Configure the setting as shown in the following example JSON code:
102+
Patch the asset endpoint with `autoAcceptUntrustedServerCertificates=true`:
77103
78-
```json
79-
"security": {
80-
"autoAcceptUntrustedServerCertificates": true
81-
}
104+
```bash
105+
ENDPOINT_NAME=<name-of-you-endpoint-here>
106+
kubectl patch AssetEndpointProfile $ENDPOINT_NAME \
107+
-n azure-iot-operations \
108+
--type=merge \
109+
-p '{"spec":{"additionalConfiguration":"{\"applicationName\":\"'"$ENDPOINT_NAME"'\",\"security\":{\"autoAcceptUntrustedServerCertificates\":true}}"}}'
82110
```
83111
112+
> [!WARNING]
113+
> Don't use untrusted certificates in production environments.
114+
84115
## Related content
85116

86117
- [Autodetect assets using Azure IoT Akri Preview](howto-autodetect-opcua-assets-using-akri.md)

0 commit comments

Comments
 (0)