Skip to content

Commit 4ca1fc1

Browse files
committed
add Bicep quickstart
1 parent a9b2f86 commit 4ca1fc1

File tree

2 files changed

+168
-7
lines changed

2 files changed

+168
-7
lines changed
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
---
2+
title: Run Azure IoT Edge on Ubuntu Virtual Machines by using Bicep | Microsoft Docs
3+
description: Azure IoT Edge setup instructions for Ubuntu LTS Virtual Machines by using Bicep
4+
author: toolboc
5+
ms.service: iot-edge
6+
services: iot-edge
7+
ms.topic: conceptual
8+
ms.date: 08/29/2022
9+
ms.author: pdecarlo
10+
11+
---
12+
# Run Azure IoT Edge on Ubuntu Virtual Machines by using Bicep
13+
14+
[!INCLUDE [iot-edge-version-201806-or-202011](../../includes/iot-edge-version-201806-or-202011.md)]
15+
16+
The Azure IoT Edge runtime is what turns a device into an IoT Edge device. The runtime can be deployed on devices as small as a Raspberry Pi or as large as an industrial server. Once a device is configured with the IoT Edge runtime, you can start deploying business logic to it from the cloud.
17+
18+
To learn more about how the IoT Edge runtime works and what components are included, see [Understand the Azure IoT Edge runtime and its architecture](iot-edge-runtime.md).
19+
20+
:::moniker range="iotedge-2018-06"
21+
This article lists the steps to deploy an Ubuntu 18.04 LTS virtual machine with the Azure IoT Edge runtime installed and configured using a pre-supplied device connection string. The deployment is accomplished using a [cloud-init](../virtual-machines/linux/using-cloud-init.md) based [Bicep file](../azure-resource-manager/bicep/overview.md) maintained in the [iotedge-vm-deploy](https://github.com/Azure/iotedge-vm-deploy/tree/1.1) project repository.
22+
23+
On first boot, the virtual machine [installs the latest version of the Azure IoT Edge runtime via cloud-init](https://github.com/Azure/iotedge-vm-deploy/blob/1.1/cloud-init.txt). It also sets a supplied connection string before the runtime starts, allowing you to easily configure and connect the IoT Edge device without the need to start an SSH or remote desktop session.
24+
:::moniker-end
25+
:::moniker range=">=iotedge-2020-11"
26+
This article lists the steps to deploy an Ubuntu 20.04 LTS virtual machine with the Azure IoT Edge runtime installed and configured using a pre-supplied device connection string. The deployment is accomplished using a [cloud-init](../virtual-machines/linux/using-cloud-init.md) based [Bicep file](../azure-resource-manager/bicep/overview.md) maintained in the [iotedge-vm-deploy](https://github.com/Azure/iotedge-vm-deploy/tree/1.3) project repository.
27+
28+
On first boot, the virtual machine [installs the latest version of the Azure IoT Edge runtime via cloud-init](https://github.com/Azure/iotedge-vm-deploy/blob/1.3/cloud-init.txt). It also sets a supplied connection string before the runtime starts, allowing you to easily configure and connect the IoT Edge device without the need to start an SSH or remote desktop session.
29+
:::moniker-end
30+
31+
## Deploy from Azure CLI
32+
33+
You can't deploy a remote Bicep file. Save a copy of the [Bicep file](https://raw.githubusercontent.com/Azure/iotedge-vm-deploy/master/edgeDeploy.bicep) locally as **main.bicep**.
34+
35+
1. Ensure that you have installed the Azure CLI iot extension with:
36+
37+
```azurecli-interactive
38+
az extension add --name azure-iot
39+
```
40+
41+
1. Next, if you're using Azure CLI on your desktop, start by logging in:
42+
43+
```azurecli-interactive
44+
az login
45+
```
46+
47+
1. If you have multiple subscriptions, select the subscription you'd like to use:
48+
1. List your subscriptions:
49+
50+
```azurecli-interactive
51+
az account list --output table
52+
```
53+
54+
1. Copy the SubscriptionID field for the subscription you'd like to use.
55+
56+
1. Set your working subscription with the ID that you copied:
57+
58+
```azurecli-interactive
59+
az account set -s <SubscriptionId>
60+
```
61+
62+
1. Create a new resource group (or specify an existing one in the next steps):
63+
64+
```azurecli-interactive
65+
az group create --name IoTEdgeResources --location westus2
66+
```
67+
68+
1. Create a new virtual machine:
69+
:::moniker range="iotedge-2018-06"
70+
To use an **authenticationType** of `password`, see the example below:
71+
72+
```azurecli-interactive
73+
az deployment group create \
74+
--resource-group IoTEdgeResources \
75+
--template-file "main.bicep" \
76+
--parameters dnsLabelPrefix='my-edge-vm1' \
77+
--parameters deviceConnectionString=$(az iot hub device-identity connection-string show --device-id <REPLACE_WITH_DEVICE-NAME> --hub-name <REPLACE-WITH-HUB-NAME> -o tsv) \
78+
--parameters authenticationType='password' \
79+
--parameters adminUsername='<REPLACE_WITH_USERNAME>' \
80+
--parameters adminPasswordOrKey="<REPLACE_WITH_SECRET_PASSWORD>"
81+
```
82+
83+
To authenticate with an SSH key, you may do so by specifying an **authenticationType** of `sshPublicKey`, then provide the value of the SSH key in the **adminPasswordOrKey** parameter. An example is shown below.
84+
85+
```azurecli-interactive
86+
#Generate the SSH Key
87+
ssh-keygen -m PEM -t rsa -b 4096 -q -f ~/.ssh/iotedge-vm-key -N ""
88+
89+
#Create a VM using the iotedge-vm-deploy script
90+
az deployment group create \
91+
--resource-group IoTEdgeResources \
92+
--template-file "main.bicep" \
93+
--parameters dnsLabelPrefix='my-edge-vm1' \
94+
--parameters deviceConnectionString=$(az iot hub device-identity connection-string show --device-id <REPLACE_WITH_DEVICE-NAME> --hub-name <REPLACE-WITH-HUB-NAME> -o tsv) \
95+
--parameters authenticationType='sshPublicKey' \
96+
--parameters adminUsername='<REPLACE_WITH_USERNAME>' \
97+
--parameters adminPasswordOrKey="$(< ~/.ssh/iotedge-vm-key.pub)"
98+
```
99+
:::moniker-end
100+
:::moniker range=">=iotedge-2020-11"
101+
To use an **authenticationType** of `password`, see the example below:
102+
103+
```azurecli-interactive
104+
az deployment group create \
105+
--resource-group IoTEdgeResources \
106+
--template-file "main.bicep" \
107+
--parameters dnsLabelPrefix='my-edge-vm1' \
108+
--parameters deviceConnectionString=$(az iot hub device-identity connection-string show --device-id <REPLACE_WITH_DEVICE-NAME> --hub-name <REPLACE-WITH-HUB-NAME> -o tsv) \
109+
--parameters authenticationType='password' \
110+
--parameters adminUsername='<REPLACE_WITH_USERNAME>' \
111+
--parameters adminPasswordOrKey="<REPLACE_WITH_SECRET_PASSWORD>"
112+
```
113+
114+
To authenticate with an SSH key, you may do so by specifying an **authenticationType** of `sshPublicKey`, then provide the value of the SSH key in the **adminPasswordOrKey** parameter. An example is shown below.
115+
116+
```azurecli-interactive
117+
#Generate the SSH Key
118+
ssh-keygen -m PEM -t rsa -b 4096 -q -f ~/.ssh/iotedge-vm-key -N ""
119+
120+
#Create a VM using the iotedge-vm-deploy script
121+
az deployment group create \
122+
--resource-group IoTEdgeResources \
123+
--template-file "main.bicep" \
124+
--parameters dnsLabelPrefix='my-edge-vm1' \
125+
--parameters deviceConnectionString=$(az iot hub device-identity connection-string show --device-id <REPLACE_WITH_DEVICE-NAME> --hub-name <REPLACE-WITH-HUB-NAME> -o tsv) \
126+
--parameters authenticationType='sshPublicKey' \
127+
--parameters adminUsername='<REPLACE_WITH_USERNAME>' \
128+
--parameters adminPasswordOrKey="$(< ~/.ssh/iotedge-vm-key.pub)"
129+
```
130+
:::moniker-end
131+
132+
1. Verify that the deployment has completed successfully. A virtual machine resource should have been deployed into the selected resource group. Take note of the machine name, this should be in the format `vm-0000000000000`. Also, take note of the associated **DNS Name**, which should be in the format `<dnsLabelPrefix>`.`<location>`.cloudapp.azure.com.
133+
134+
The **DNS Name** can be obtained from the JSON-formatted output of the previous step, within the **outputs** section as part of the **public SSH** entry. The value of this entry can be used to SSH into to the newly deployed machine.
135+
136+
```bash
137+
"outputs": {
138+
"public SSH": {
139+
"type": "String",
140+
"value": "ssh <adminUsername>@<DNS_Name>"
141+
}
142+
}
143+
```
144+
145+
The **DNS Name** can also be obtained from the **Overview** section of the newly deployed virtual machine within the Azure portal.
146+
147+
> [!div class="mx-imgBorder"]
148+
> [![Screenshot showing the dns name of the iotedge vm](./media/how-to-install-iot-edge-ubuntuvm/iotedge-vm-dns-name.png)](./media/how-to-install-iot-edge-ubuntuvm/iotedge-vm-dns-name.png)
149+
150+
1. If you want to SSH into this VM after setup, use the associated **DNS Name** with the command:
151+
`ssh <adminUsername>@<DNS_Name>`
152+
153+
## Next steps
154+
155+
Now that you have an IoT Edge device provisioned with the runtime installed, you can [deploy IoT Edge modules](how-to-deploy-modules-portal.md).
156+
157+
If you are having problems with the IoT Edge runtime installing properly, check out the [troubleshooting](troubleshoot.md) page.
158+
159+
To update an existing installation to the newest version of IoT Edge, see [Update the IoT Edge security daemon and runtime](how-to-update-iot-edge.md).
160+
161+
If you'd like to open up ports to access the VM through SSH or other inbound connections, refer to the Azure Virtual Machines documentation on [opening up ports and endpoints to a Linux VM](../virtual-machines/linux/nsg-quickstart.md)

articles/iot-edge/how-to-install-iot-edge-ubuntuvm.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ms.service: iot-edge
99
services: iot-edge
1010
ms.topic: conceptual
1111
ms.date: 01/20/2022
12-
ms.author: pdecarlo
12+
ms.author: pdecarlo
1313

1414
---
1515
# Run Azure IoT Edge on Ubuntu Virtual Machines
@@ -33,7 +33,7 @@ On first boot, the virtual machine [installs the latest version of the Azure IoT
3333

3434
## Deploy using Deploy to Azure Button
3535

36-
The [Deploy to Azure Button](../azure-resource-manager/templates/deploy-to-azure-button.md) allows for streamlined deployment of [Azure Resource Manager templates](../azure-resource-manager/templates/overview.md) maintained on GitHub. This section will demonstrate usage of the Deploy to Azure Button contained in the [iotedge-vm-deploy](https://github.com/Azure/iotedge-vm-deploy) project repository.
36+
The [Deploy to Azure Button](../azure-resource-manager/templates/deploy-to-azure-button.md) allows for streamlined deployment of [Azure Resource Manager templates](../azure-resource-manager/templates/overview.md) maintained on GitHub. This section will demonstrate usage of the Deploy to Azure Button contained in the [iotedge-vm-deploy](https://github.com/Azure/iotedge-vm-deploy) project repository.
3737

3838
1. We will deploy an Azure IoT Edge enabled Linux VM using the iotedge-vm-deploy Azure Resource Manager template. To begin, click the button below:
3939
:::moniker range="iotedge-2018-06"
@@ -123,18 +123,18 @@ The [Deploy to Azure Button](../azure-resource-manager/templates/deploy-to-azure
123123
--resource-group IoTEdgeResources \
124124
--template-uri "https://raw.githubusercontent.com/Azure/iotedge-vm-deploy/1.1/edgeDeploy.json" \
125125
--parameters dnsLabelPrefix='my-edge-vm1' \
126-
--parameters adminUsername='<REPLACE_WITH_USERNAME>' \
127126
--parameters deviceConnectionString=$(az iot hub device-identity connection-string show --device-id <REPLACE_WITH_DEVICE-NAME> --hub-name <REPLACE-WITH-HUB-NAME> -o tsv) \
128127
--parameters authenticationType='password' \
128+
--parameters adminUsername='<REPLACE_WITH_USERNAME>' \
129129
--parameters adminPasswordOrKey="<REPLACE_WITH_SECRET_PASSWORD>"
130130
```
131131

132132
To authenticate with an SSH key, you may do so by specifying an **authenticationType** of `sshPublicKey`, then provide the value of the SSH key in the **adminPasswordOrKey** parameter. An example is shown below.
133133

134134
```azurecli-interactive
135135
#Generate the SSH Key
136-
ssh-keygen -m PEM -t rsa -b 4096 -q -f ~/.ssh/iotedge-vm-key -N ""
137-
136+
ssh-keygen -m PEM -t rsa -b 4096 -q -f ~/.ssh/iotedge-vm-key -N ""
137+
138138
#Create a VM using the iotedge-vm-deploy script
139139
az deployment group create \
140140
--resource-group IoTEdgeResources \
@@ -164,8 +164,8 @@ The [Deploy to Azure Button](../azure-resource-manager/templates/deploy-to-azure
164164

165165
```azurecli-interactive
166166
#Generate the SSH Key
167-
ssh-keygen -m PEM -t rsa -b 4096 -q -f ~/.ssh/iotedge-vm-key -N ""
168-
167+
ssh-keygen -m PEM -t rsa -b 4096 -q -f ~/.ssh/iotedge-vm-key -N ""
168+
169169
#Create a VM using the iotedge-vm-deploy script
170170
az deployment group create \
171171
--resource-group IoTEdgeResources \

0 commit comments

Comments
 (0)