|
| 1 | +# Door Monitor |
| 2 | + |
| 3 | +## Steps to start |
| 4 | + |
| 5 | +1. Setup development environment by following [Get Started](https://microsoft.github.io/azure-iot-developer-kit/docs/get-started/) |
| 6 | +1. Open VS Code |
| 7 | +1. Press **F1** or **Ctrl + Shift + P** - `IoT Workbench: Examples` and select DoorMonitor |
| 8 | + |
| 9 | +## Deploy SendGrid service in Azure |
| 10 | + |
| 11 | +1. click the Deploy to Azure button below and deploy SendGrid Service. |
| 12 | + |
| 13 | + [](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FIoTDevEnvExamples%2FDevKitDoorMonitor%2Fdeploy%2FSendGridDeploy%2Fazuredeploy.json) |
| 14 | + |
| 15 | +1. After the deployment succeeds, click the resource and then click the **Manage** button. You are taken to your SendGrid page, and need to verify your email address. |
| 16 | + |
| 17 | +1. On the SendGrid page, click Settings > API Keys > Create API Key. Input the API Key Name and click Create & View. |
| 18 | + |
| 19 | +1. Copy the API key. |
| 20 | + |
| 21 | +## Creating the Azure Logic App |
| 22 | + |
| 23 | +1. Open the [Azure Portal](https://portal.azure.com) |
| 24 | +1. Select the **+** or **Create a resource** button and under **Enterprise Integration** choose **Logic App** |
| 25 | +1. Give it a Name, Resource Group, and Region (any will do) and click **Create** |
| 26 | +1. After the logic app is created, open it |
| 27 | +1. The designer should automatically load - if not click the **Edit** button |
| 28 | +1. Select the **When an HTTP request is received** trigger |
| 29 | +1. Click **New Step** to add a step to the workflow and **Add an action** |
| 30 | +1. Search for the key word of **Send email** action. |
| 31 | + > NOTE: You are more than welcome to use any action you want to perform on an IoT event |
| 32 | +1. Select the **SendGrid - Send email(V2)** action and provide the detailed information of the email. |
| 33 | +1. Authenticate this logic app by using the SendGrid API key you created before.. |
| 34 | + |
| 35 | +1. Click the **Save** button to save this serverless workflow. |
| 36 | +1. Click the **When a HTTP request is received** card to open and reveal the URL generated after saving. Copy that URL. |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | +## Provision Azure Services |
| 41 | + |
| 42 | +1. Press **F1** or **Ctrl + Shift + P** in Visual Studio Code - **IoT Workbench:Cloud** and click **Azure Provision** |
| 43 | +1. Select a subscription. |
| 44 | +1. Select or choose a resource group. |
| 45 | +1. Select or create an IoT Hub. |
| 46 | +1. Wait for the deployment. |
| 47 | +1. Select or create an IoT Hub device. Please take a note of the device name. |
| 48 | +1. Create Function App. |
| 49 | +1. Wait for the deployment. |
| 50 | + |
| 51 | +## Deploy Function App |
| 52 | +1. Open shakeshake\run.csx and modify the following line with the URL you created in the previous step. |
| 53 | +``` |
| 54 | +var response = await client.PostAsync("https://prod-1....", httpContent); |
| 55 | +``` |
| 56 | +1. ress **F1** or **Ctrl + Shift + P** in Visual Studio Code - **IoT Workbench: Cloud** and click **Azure Deploy**. |
| 57 | +1. Wait for function app code uploading. |
| 58 | + |
| 59 | +## Configure IoT Hub Device Connection String in DevKit |
| 60 | + |
| 61 | +1. Connect your DevKit to your machine. |
| 62 | +1. Press **F1** or **Ctrl + Shift + P** in Visual Studio Code - **IoT Workbench: Device** and click **config-device-connection**. |
| 63 | +1. Hold button A on DevKit, then press rest button, and then release button A to enter config mode. |
| 64 | +1. Wait for connection string configuration to complete. |
| 65 | + |
| 66 | +## Upload Arduino Code to DevKit |
| 67 | + |
| 68 | +1. Connect your DevKit to your machine. |
| 69 | +1. Press **F1** or **Ctrl + Shift + P** in Visual Studio Code - **IoT Workbench:Device** and click **Device Upload**. |
| 70 | +1. Wait for arduino code uploading. |
0 commit comments