Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
IoT Edge 1.5
Important
IoT Edge 1.5 LTS is the supported release. IoT Edge 1.4 LTS is end of life as of November 12, 2024. If you are on an earlier release, see Update IoT Edge.
The Azure IoT Edge runtime turns a device into an IoT Edge device. You can deploy the runtime on devices as small as a Raspberry Pi or as large as an industrial server. After you set up the IoT Edge runtime, deploy business logic to the device from the cloud.
To learn more about how the IoT Edge runtime works and what components it includes, see Understand the Azure IoT Edge runtime and its architecture.
Deploy from Azure CLI
You can't deploy a remote Bicep file. Save a copy of the Bicep file locally as main.bicep.
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 cloud set -n AzureChinaCloud az login # az cloud set -n AzureCloud //means return to Public Azure.
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 want to use.
Set your working subscription with the ID 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 chinanorth2
Create a new virtual machine:
To use an authenticationType of
password
, see the following example:az deployment group create \ --resource-group IoTEdgeResources \ --template-file "main.bicep" \ --parameters dnsLabelPrefix='my-edge-vm1' \ --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 adminUsername='<REPLACE_WITH_USERNAME>' \ --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 theadminPasswordOrKey
parameter. For 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-file "main.bicep" \ --parameters dnsLabelPrefix='my-edge-vm1' \ --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 adminUsername='<REPLACE_WITH_USERNAME>' \ --parameters adminPasswordOrKey="$(< ~/.ssh/iotedge-vm-key.pub)"
Check that the deployment completed successfully. A virtual machine resource is deployed into the selected resource group. Note the machine name, which is in the format
vm-0000000000000
. Also, note the associated DNS Name, which is in the format<dnsLabelPrefix>
.<location>
.cloudapp.chinacloudapi.cn.You can get the DNS Name from the JSON-formatted output of the previous step, in the outputs section as part of the public SSH entry. Use this value to SSH into the newly deployed machine.
"outputs": { "public SSH": { "type": "String", "value": "ssh <adminUsername>@<DNS_Name>" } }
You can also get the DNS Name from the Overview section of the newly deployed virtual machine in 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're 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.