2. Deploying Azure Resources - great-lakes/lean-iot GitHub Wiki

Deploying Azure Resources

Prerequisites

The following are required to complete this lab:

  • An MXChip IoT DevKit
  • A computer
  • An available WiFi connection or mobile hotspot. Note that the WiFi connection can (and should) be secure, but it must be ungated (i.e. no intermediate login page is required. Gated WiFi is common in public venues and hotels).

Exercises

This lab includes the following exercises:

Estimated time to complete this lab: 15 minutes.

Exercise 1: Provision an Azure IoT Hub

Azure IoT Hubs enable IoT devices to connect securely to the cloud and transmit messages (events) that can be sent to other sources such as mobile apps, websites and etc.

In this exercise, you will provision an Azure IoT Hub for your MXChip to transmit events to.

  1. Open the Azure Portal in your browser. If asked to log in, do so using your Microsoft account.

  2. Click + New, followed by Internet of Things and IoT Hub.

    The Azure Portal quick start menu shows the selection to add a new IoT Hub to a subscription.

    Provisioning a new IoT Hub

  3. Enter 'Flysim' and then your initals for IoT Hub in the Name field. IoT Hub names must be unique across Azure, so make sure a green check mark appears next to it. Also make sure S1 - Standard is selected as the pricing tier. Select New under Resource group and enter the resource-group name "FlySim" (i.e. flysimgac). Select East US as the Location (important!). Accept the default values everywhere else, and then click Create.

    You selected East US as the location because in Lab 3, the instructor will create Azure resources in that same region for the IoT Hub to connect to. Azure resources can be connected across regions, but keeping everything within the same data center reduces cost and minimizes latency.

    The Azure Portal's IoT Hub Configuration pane shows relevant configuration settings.  The pricing tier is set to S1, and a single unit of IoT Hub and 4 Device-to-cloud partitions are entered.

    Configuring an IoT Hub

  4. Click Resource groups in the ribbon on the left side of the portal, and then click FlySim to open the resource group.

    The Azure Portal's Resource Groups pane displays the newly created IoT Hub.

    Opening the resource group

    The Asure Portal's Resource Group indicates that the IoT Hub deployment completed successfully.

  5. Wait until "Deploying" changes to "Succeeded," indicating that the IoT Hub has been provisioned. You can click the Refresh button at the top of the blade to refresh the deployment status.

Exercise 2: Provision an Azure storage account

Before you deploy an Azure Function, you need to create a repository for the Function's code, logs, and history. In this exercise, you will create an Azure storage account for that purpose.

  1. Return to the Azure Portal. Click + New, followed by Storage and Storage account.

    Creating a new storage account

    Creating a new storage account

  2. Enter 'Flysim' and then your initals for the storage account and make sure a green check mark appears next to it. Select Use existing under Resource group and select the "FlySim" resource group you created in exercise 1. Choose East US as the Location, and then click the Create button, and everything else as default.

    Creating a new storage account

    Creating a new storage account

Now that the storage account has been created, it's time to create an Azure Function to transform accelerometer data that will reach the IoT Hub you created in Exercise 1

Exercise 3: Provision an Azure Function

Before you deploy an Azure Function, you need to create a repository for the Function's code, logs, and history. In this exercise, you will create an Azure storage account for that purpose.

  1. Return to the Azure Portal. Click + New, followed by Compute and Function App.

    Creating a new azure function

    Creating a new azure function

  2. Enter 'Flysim' and then your initals for the azure function and make sure a green check mark appears next to it. Select Use existing under Resource group and select the "FlySim" resource group you created in exercise 1. Choose East US as the Location. Select Use existing under Storage and select the "FlySim(YOUR_INITIALS)" storage account you made in exercise 2. and then click the Create button.

    configure new azure function

    configure new azure function

Summary

In this lab, you created an Azure IoT Hub, Azure Storage Account and Azure Function. Next we will deploy code to your Azure function and to your MXChip!

Next Steps: Writing your Azure Function

Now that your resources are created, Let's add some code to your Azure Function!