Run Azure IoT Edge on Ubuntu Virtual Machines
Applies to: IoT Edge 1.5
IoT Edge 1.4
Important
IoT Edge 1.5 LTS and IoT Edge 1.4 LTS are supported releases. IoT Edge 1.4 LTS is end of life on November 12, 2024. If you are on an earlier release, see Update IoT Edge.
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.
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.
This article lists the steps to deploy an Ubuntu virtual machine with the Azure IoT Edge runtime installed and configured using a presupplied device connection string. The deployment is accomplished using a cloud-init based Azure Resource Manager template maintained in the iotedge-vm-deploy project repository.
On first boot, the virtual machine installs the latest version of the Azure IoT Edge runtime via cloud-init. 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.
Deploy using Deploy to Azure Button
The Deploy to Azure Button allows for streamlined deployment of Azure Resource Manager templates maintained on GitHub. This section demonstrates usage of the Deploy to Azure Button contained in the iotedge-vm-deploy project repository.
You will deploy an Azure IoT Edge enabled Linux VM using the iotedge-vm-deploy Azure Resource Manager template. To begin, select the following button:
On the newly launched window, fill in the available form fields:
Field Description Subscription The active Azure subscription to deploy the virtual machine into. Resource group An existing or newly created Resource Group to contain the virtual machine and it's associated resources. Region The geographic region to deploy the virtual machine into, this value defaults to the location of the selected Resource Group. DNS Label Prefix A required value of your choosing that is used to prefix the hostname of the virtual machine. Admin Username A username that is provided root privileges on deployment. Device Connection String A device connection string for a device that was created within your intended IoT Hub. VM Size The size of the virtual machine to be deployed. Ubuntu OS Version The version of the Ubuntu OS to be installed on the base virtual machine. Authentication Type Choose sshPublicKey or password depending on your preference. Admin Password or Key The value of the SSH Public Key or the value of the password depending on the choice of Authentication Type. Select
Next : Review + create
to review the terms and select Create to begin the deployment.Verify that the deployment completed successfully. A virtual machine resource is 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.The DNS Name can be obtained from the Overview section of the newly deployed virtual machine within the Azure portal.
If you want to SSH into this VM after setup, use the associated DNS Name with the command:
ssh <adminUsername>@<DNS_Name>
Deploy from Azure CLI
Ensure that you installed the Azure CLI iot extension with:
az extension add --name azure-iot
Next, if you're using Azure CLI on your desktop, start by logging in:
az login
If you have multiple subscriptions, select the subscription you'd like to use:
List your subscriptions:
az account list --output table
Copy the SubscriptionID field for the subscription you'd like to use.
Set your working subscription with the ID that you copied:
az account set -s <SubscriptionId>
Create a new resource group (or specify an existing one in the next steps):
az group create --name IoTEdgeResources --location westus2
Create a new virtual machine:
To use an authenticationType of
password
, see the following example:az deployment group create \ --resource-group IoTEdgeResources \ --template-uri "https://raw.githubusercontent.com/Azure/iotedge-vm-deploy/main/edgeDeploy.json" \ --parameters dnsLabelPrefix='my-edge-vm1' \ --parameters adminUsername='<REPLACE_WITH_USERNAME>' \ --parameters deviceConnectionString=$(az iot hub device-identity connection-string show --device-id <REPLACE_WITH_DEVICE-NAME> --hub-name <REPLACE-WITH-HUB-NAME> -o tsv) \ --parameters authenticationType='password' \ --parameters adminPasswordOrKey="<REPLACE_WITH_SECRET_PASSWORD>"
To authenticate with an SSH key, specify an authenticationType of
sshPublicKey
, then provide the value of the SSH key in the adminPasswordOrKey parameter. See the following example:#Generate the SSH Key ssh-keygen -m PEM -t rsa -b 4096 -q -f ~/.ssh/iotedge-vm-key -N "" #Create a VM using the iotedge-vm-deploy script az deployment group create \ --resource-group IoTEdgeResources \ --template-uri "https://raw.githubusercontent.com/Azure/iotedge-vm-deploy/main/edgeDeploy.json" \ --parameters dnsLabelPrefix='my-edge-vm1' \ --parameters adminUsername='<REPLACE_WITH_USERNAME>' \ --parameters deviceConnectionString=$(az iot hub device-identity connection-string show --device-id <REPLACE_WITH_DEVICE-NAME> --hub-name <REPLACE-WITH-HUB-NAME> -o tsv) \ --parameters authenticationType='sshPublicKey' \ --parameters adminPasswordOrKey="$(< ~/.ssh/iotedge-vm-key.pub)"
Verify that the deployment completed successfully. A virtual machine resource should be 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.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.
"outputs": { "public SSH": { "type": "String", "value": "ssh <adminUsername>@<DNS_Name>" } }
The DNS Name can also be obtained from the Overview section of the newly deployed virtual machine within the Azure portal.
If you want to SSH into this VM after setup, use the associated DNS Name with the command:
ssh <adminUsername>@<DNS_Name>
Next steps
Now that you have an IoT Edge device provisioned with the runtime installed, you can deploy IoT Edge modules.
If you are having problems with the IoT Edge runtime installing properly, check out the troubleshooting page.
To update an existing installation to the newest version of IoT Edge, see Update the IoT Edge security daemon and runtime.
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.
Aiseolas
https://aka.ms/ContentUserFeedback.
Ag teacht go luath: Le linn 2024 beimid ag cur deireadh de réir a chéile le fadhbanna GitHub mar mheicníocht aiseolais d’inneachar agus córas aiseolais nua a chur ina áit. Chun tuilleadh faisnéise a fháil féach ar :Cuir isteach agus féach ar aiseolas le haghaidh