Connect Azure Sphere to Ethernet

You can connect an Ethernet-enabled Azure Sphere device to a public (internet-connected) network and communicate with Azure IoT or your own cloud services, or you can connect it to a private network and use network services.

Prepare Azure Sphere for Ethernet

To communicate over Ethernet, an Azure Sphere device requires an external Ethernet adapter and a board configuration image. The board configuration image contains information that the Azure Sphere Security Service requires to add support for Ethernet to the Azure Sphere OS. See Prepare Azure Sphere for Ethernet, which describes how to connect a supported adapter to your Azure Sphere device, create and deploy a board configuration image package file, and enable the Ethernet interface.

Configure Azure Sphere for Ethernet

After connecting your Azure Sphere device to a supported Ethernet adapter and deploying the board configuration image, you can configure your Azure Sphere device to connect to a network from the command line (CLI) or from your application using the Azure Sphere SDK Application Libraries (Applibs).

Ethernet configuration using the CLI

To manage Ethernet configuration from the command line, you use the azsphere device network CLI commands. For example, the device network enable command enables an ethernet interface on the attached device.

azsphere device network enable --interface "eth0" 

To use the configured Ethernet network, the network interface (eth0) must be active. Use the device network list-interfaces command to determine if the interface is active.


azsphere device network list-interfaces

Use the device network enable command to activate it if necessary.


azsphere device network enable --interface eth0

Ethernet configuration using Applibs

To configure Ethernet, your application must use the applibs networking API.

Include this header file in your application:

#include <applibs/networking.h>

The application manifest must include the NetworkConfig capability.

 "Capabilities": {
  "NetworkConfig" : true
}

You use the Networking_GetInterfaceConnectionStatus function to determine if the network interface is active.

Networking_GetInterfaceConnectionStatus("eth0", &currentInterfaceStatus);

To activate the network interface, use the Networking_SetInterfaceState function.

Networking_SetInterfaceState("eth0", true);

Note

If both network interfaces (wlan0 and eth0) are active and connected, the specific interface the device will use for communication is non-deterministic. If you want to control which network interface is used at any given time your application must use the Networking_SetInterfaceState() function to explicitly turn the desired interface on and the other interface off. The DHCP client high-level app sample demonstrates among other things, how to switch between interfaces by assigning a value representing one of the two interfaces to a global variable.

Samples

Azure IoT demonstrates how to use the Azure IoT SDK C APIs in an Azure Sphere application to communicate with Azure IoT Hub or Azure IoT Central.

DHCP client high-level app demonstrates how to renew or release the current IP address that the network's DHCP server has assigned to the MT3620 device.

HTTPS cURL Easy demonstrates fetching content over HTTPS using cURL's 'easy' API

HTTPS cURL Multi demonstrates fetching content over HTTPS using cURL's 'multi' API.

Power Down high-level app demonstrates Power Down functionality for the Azure Sphere platform.

Private network services demonstrates how to connect an Azure Sphere device to a private network and use network services.

WolfSSL high-level app demonstrates using WolfSSL for SSL handshake in a high-level application.

Note

The following samples are from the Azure Sphere Gallery, which is a collection of unmaintained software and hardware samples from Microsoft. For more information, see Azure Sphere Gallery.

Print MAC and IP address of network interface prints the MAC and IP addresses of a specified network interface.

OSNetworkRequirementChecker-HLApp performs two device (MT3620) networking diagnostic tests.