- Azure Sphere - First Setup
To be able to use the Azure Sphere to its full potential, one needs to go through sometimes confusing steps to start developing/using the device properly.
The first place you want to go is the Microsoft docs for Azure Sphere. I've found it pretty straight forward but stumbled upon some inconsistencies along the way. Maybe I was off in the first steps after unboxing the Sphere but I had to skip back and forth to get the Sphere properly registered and ready to be used. So don't be alarmed if we will not be going exactly through the setup as the MS Docs are structured. Let's jump right to it!
I will not delve on this part much longer. If you are intending to play with Azure Sphere I think you are already set up but here are the basics:
- A PC running Windows 10 Anniversary Update or later
- Visual Studio Community 2017 version 15.9 or later
For full development capabilities, you will need to install the Azure Sphere SDK. It's in preview and it will add two templates to your Visual Studio project menu. It also includes important Azure Sphere Developer Command Prompt. I would recommend rebooting your machine after installing it.
Windows 10 should automatically install the device drivers. It did for me: see my dev environment set from the previous article. The installation should take only up to a minute. After it, you should see your Sphere under Devices in the settings menu.
Here's the first caveat that comes into play. To register the Azure Sphere with your Azure subscription, you need to 'claim' the device. What 'claim' means? This action will do one time pairing with your Azure Tenant. This action is irreversible and the device becomes non-transferable. That means when in the future, you will decide to close your Azure account for any reason (for example in migration scenario) the Sphere will be 'closed' with it. Sure, you can still use the hardware but you will not be protected with Azure Security service and you will not be able to connect the Sphere to a different tenant.
Now how to set up the account for the Sphere. If you have work/school account you are good to go. Only admin consent will be required.
I went with the latter => the scenario where you have to create a work/school account that is associated with your personal Microsoft account. To do this, go to https://portal.azure.com and find Azure Active directory. Before you will create a user that will have admin privileges to your Azure Sphere tenant you will need your trusted domain. This information is located under 'Custom domain names' in the AAD menu. It should look like this:
Now let's create the user. Go to 'Users' and click '+New User'. You can name it as you want. The user name must be structured as
<sphere-admin-name>@<your-trusted-domain>.onmicrosoft.com. So for example
firstname.lastname@example.org. Directory role can stay on the 'User' level. And that's it!
If you already have an Azure Sphere Tenant, you can safely skip this step.
Fire up the Azure Sphere Command prompt and type
azsphere login. Sign in with the account that we have just created. Once completed type the following
azsphere tenant create --name <my-tenant> where
<my-tenant> is the name of your about to be created, Azure Sphere tenant. The tenant should be created momentarily.
Claiming the device is pretty straight forward and as a plus, you are already signed in. Still in the Sphere command prompt, type
azsphere device claim. If successful, this output should present itself in the CLI:
Claiming device. Claiming attached device ID '<device ID>' into tenant ID '<tenant ID'. Successfully claimed device ID '<device ID>' into tenant ID '<tenant ID'. Command completed successfully in 00:00:05.5459143.
To connect to your local Wi-Fi spot to receive OTA (over-the-air) updated and remote deployment, type this command to the still opened Azure Sphere command prompt where
<yourSSID> is the name of your Wi-fi access point and
<yourNetworkKey> is your password.
azsphere device wifi add --ssid <yourSSID> --key <yourNetworkKey>
To check whether the connection is stable, use this command:
azsphere device wifi show-status
And the output should look like this:
SSID : <yourSSID> Configuration state : enabled Connection state : connected Security state : psk Frequency : 2442 Mode : station Key management : WPA2-PSK WPA State : COMPLETED IP Address : 192.168.45.34 MAC Address : 52:cf:ff:3a:76:1b Command completed successfully in 00:00:01.3976308.
Now that we have everything properly set up. We can update the operating system on the board itself. In the command prompt type
azsphere device show-ota-status. It can take up to 30 minutes the OTA update is delivered. I've kept the device connected to the PC by the USB just to be sure the updates will be delivered as there is no progress bar. To check the version of the OS just type
If you for any reason encounter any errors during the setup, I recommend to unplug the board and plug back in for it to be restarted. You can also push and hold the RESET button for 5 seconds. Here is the official troubleshooting Docs page if you will be truly stuck.