Azure IoT solution integration: Step-by-Step guide
This article came up from the need to have a guidance step-by-step for Azure beginners on the IoT integration and from the guidance from Ranga Vadlamudi
Goals
- Stream data to time series insights
- Stream data to cosmos db using azure stream analytics
- Code for cosmos db change feeds and invoke azure functions
https://camo.githubusercontent.com/cfaae43b53edf04b4b9cf7ce5ba6cdf10557e52a/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f30362d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Overview
- Setup MXCHIMP
- Connect mxchip to iothub
- Simulator: https://azure-samples.github.io/iot-devkit-web-simulator/
https://camo.githubusercontent.com/d66a69556687eae5e06f69ebd04423cb478304f4/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f30312d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Steps
Connect to wifi
- Put the device into AP mode by doing the following:
- Press and hold the B button
- With the B button held down, press and release the Reset button
- Release the B button
- Verify that an SSID and an IP address appear on the device screen. The IP address is the one that we will use to connect to the device from our laptop.
https://camo.githubusercontent.com/88ce3cafb5854653cb8c641b4da56857c6e8d442/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f30322d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
https://camo.githubusercontent.com/3a467da632039ec0935e3709adcaf6564f5dd4c9/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f30332d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
https://camo.githubusercontent.com/fc8bd8483d8cca779e6fc43a423c13994d8cee76/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f30342d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
https://camo.githubusercontent.com/52b78e5532a16affe508ed1d69e219db41da4326/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f30352d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Create IoT Hub:
Go to the Azure Portal, click Create New Resource and type Iot Hub,
https://camo.githubusercontent.com/ac23ae2ad8340b63ac1a552988b650d449a7e4ec/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f30372d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702d322e706e67
Select IoT Hub and click create
https://camo.githubusercontent.com/5c05b6f0dbf2b7011e0c9451ca98d78296599a71/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f30382d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702d322e706e67
Select Create IoT hub
https://camo.githubusercontent.com/ef0d2e988f5e7d043a037a4399069dbb716741b8/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f30392d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702d322e706e67
https://camo.githubusercontent.com/e045da10b568ebebad825c6573f9c4ed25ecc2f7/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3031302d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702d322e706e67
Set up Time Series Insight
Now we will create a Time Series Insight service.
Go to the Azure Portal, click on Create New Resource and type Time Series Insights as shown below:
https://camo.githubusercontent.com/ca95915ff2b2f06d285253031e2f6e06c0eef13e/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3031312d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Then select Time Series Insights:
https://camo.githubusercontent.com/4b6f511e13ca5d6239a2b6343e2462565576271f/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3031322d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Click create:
https://camo.githubusercontent.com/d2cd0837a6056371e9b945c76530c187e816f7c2/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3031332d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Now we will provide the environment parameters as follows:
- Environment name: gab2018-cdmx
- Subscription - your Azure Pass / Subscription
- Resource group: gab2018-cdmx
- Location: West Europe
- SKU: S1
https://camo.githubusercontent.com/6cd36ccd8d1835111adaea91bf53e31cab70efe5/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3031342d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
**Note: In case we are using an Azure Pass, please review the cost $150 per month!
https://camo.githubusercontent.com/8bb6ef36e4b7772d76df228971d379d6442192f5/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3031352d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Then Check the pin to the dashboard and click create.
It is important to have a consumer group for TSI (Time Series Insights), go to the IoT Hub, click Endpoints, select Events
https://camo.githubusercontent.com/d7e98fa1bac2ade913f605d071402e22536335c6/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3031362d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Now we will create a New Consumer Group and then click save:
https://camo.githubusercontent.com/31e5f378ea3b2edd0b451ba1662b56b9ce8e946c/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3031372d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Now go back to Time Series Insights, click on Event Sources and Click on Add:
https://camo.githubusercontent.com/4eba5737093924abb832faa665b88b2be9d4aa0c/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3031382d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
We will provide the following parameters to create the Event Source:
- Event source name: gab2018cdmx
- source: IoT Hub
- Import Option: user IoT Hub from available subscription
- Subscription ID. VS Enterprise / Azure Pass
- IoT Hub name: gab2018-cdmx
- IoT Hub policy name: iothubowner
- IoT consumer group: gabevents
- Serialization format: json
Click create
https://camo.githubusercontent.com/6737af84814299f15a31eee3f2d31264f46ddc38/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3031392d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
https://camo.githubusercontent.com/1b8e8d7c3157391d2eab31fdd1b48f65aa35172d/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3032302d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Now go to overview and click go to the environment:
https://camo.githubusercontent.com/d82772183853202de24f7fbd49f3d352dbe70512/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3032312d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
**Note: We will add data access policies later. We will not be able to access the data in the environment with no data access policies defined.
We will see a screen like below:
https://camo.githubusercontent.com/97a580f6225bdddd4f39f21e75d3b0b5f1039a09/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3032322d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Create a Stream analytics Job
Now go back to the Azure Portal, we will create a Stream analytics Job. Go to Create New Resource, type Stream analytics:
https://camo.githubusercontent.com/5227f339912bbe83f6951d242c899a04a3d62e80/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3032342d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Select stream analytics job:
- Provide the following parameters:
- Job Name: gab2018-cdmx
- Subscription: VS enterprise / Azure Pass
- Resource Group: gab2018-cdmx
- Location: West Europe
- Hosting environment: cloud
Note: if already connected the device to Wifi we could try Cloud, otherwise try using Edge and connect the device to Wifi later on
https://camo.githubusercontent.com/f10f0ad81c6f3ec1f0bda82f0e4cdcb76ccfe179/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3032362d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Create a cosmos db account.
Now we will create a cosmos db account.
Select create new resource, type cosmos db, select Azure Cosmos DB:
https://camo.githubusercontent.com/6458aa76bed14f4f09fbcfbc5eb53bb9a6fdd913/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3032372d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
https://camo.githubusercontent.com/24bb40ae029b96e3403c75a1badb2003c5e00ba3/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3032382d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
https://camo.githubusercontent.com/acbd72a765f99ecd80244aa3dce0bf2cbaaa3260/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3032392d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Click create:
Provide the following parameters:
- • ID: gab2018cdmx
- • API: SQL
- • Subscription: VS Enterprise / Azure Pass
- • Resource group: gab2018cdmx
- • Location: West Europe
Click Create
It is important to highlight that we should try to deploy all the resources in the same location to avoid future issues within the service availability
https://camo.githubusercontent.com/394165a95105dcacfd695c2c42db55f2ac05dc9b/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3033302d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Create a Logic App.
Now we will create a Logic App.
Go to Create new Resource, type logic app
https://camo.githubusercontent.com/5e7aae0273da4d38123a71966281467c162b795e/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3033312d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Select Logic App:
https://camo.githubusercontent.com/e1644e02a2ec3df88e487041a794e278279de78f/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3033322d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Click on Logic App, Create:
https://camo.githubusercontent.com/c1a8e5aa9a86a8e77e64c42ac84f04e310889edb/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3033332d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Now provide the following parameters:
- Name. gab2018cdmx
- Subscription: VS Enterprise
- Resource Group. Gab2018 cdmx
- Location: West Europe
- Log Analytics: Off (for this case we are going to enable them later on)
Click Create
https://camo.githubusercontent.com/70213275786727eaab6fac5d9b9ec5d95f23e85d/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3033342d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Now go back to the azure stream analytics job, from the blade select Input:
https://camo.githubusercontent.com/f2b6f8cb3ff290315424ec5ca34048358e2007a9/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3033352d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
The input for this will be the IoTHub we created in the resource group
Select Add stream input, then select IoT Hub:
https://camo.githubusercontent.com/de0f87d2dc9c4f349a589e00a366ccd4049be5ee/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3033362d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Provide the following parameters:
- Input alias
- Select IoT Hub from the subscription
- Subscription
- IoT Hub (Azure will automatically provide us the available IoT Hub)
- Endpoint
- Shared access policy name
- Shared access policy key
- Consumer Group
- Event serialization format (we could select None, CSV, Json, etc.) Then click save
https://camo.githubusercontent.com/7666d746708c887b1ba1036578be1705a08629e4/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3033372d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Now we will generate the Output.
Generate output
This output will be the Cosmos DB we created in the resource group
Go to the Stream Job blade and select Output:
https://camo.githubusercontent.com/1855ffc27cf1eecce0ecf233268e3895ae708fa5/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3033382d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Now click Add and select Cosmos DB.
https://camo.githubusercontent.com/01b05d180088b8bba0679c6a1162ba76565cc149/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3033392d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Provide the following parameters:
- Output alias
- Select the Option: "Select Cosmos DB from your subscription"
- Select the subscription
- Account ID
- Account key
- Database
- Collection name pattern
- Document ID
https://camo.githubusercontent.com/80e864e237d895321876e3077376cd700f6896c3/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3034302d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Please Note:
If the chosen resource and the stream analytics job are located in different regions, we will be billed to move data between regions.
Now we will define a Stream Job Function.
Go to the stream job blade and click on Overview, then click on Edit query:
https://camo.githubusercontent.com/6a2320132861099ad289eb801bd523c87ff5e2f1/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3034312d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Copy and paste the following query:
SELECT [deviceId] AS [deviceId], avg(temperature) AS avgtemp INTO CosmosDB FROM mvp-iothub GROUP BY deviceId, TumblingWindow(second, 15);
Now click save:
https://camo.githubusercontent.com/f2254535b6d1f1edc6ba8efe8d53cb1edcf39aad/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3034322d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Create an Event Hub which will receive data from Azure Function.
Now we will Create an Event Hub which will receive data from Azure Function.
TIP: Take a note of keys and name.
Go to create Resources and type Event hub:
https://camo.githubusercontent.com/20b251c637a3c708dc6ae61452c902509f1af356/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3034332d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Now select the event hubs and click create:
https://camo.githubusercontent.com/11a54c1987dfc4191871b93118ede979c2914d7b/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3034352d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
https://camo.githubusercontent.com/4f4df6da89846f2dcccc0b5cb98b6ca422252b55/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3034362d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Provide the following parameters and click create:
- Name
- Pricing tier
- Subscription
- Resource Group
- Location
- Throughput units
- Enable auto-inflate
- Specify upper limit to 20
https://camo.githubusercontent.com/00c1c5603847ca78c29c85bdd11986409ec345be/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3034372d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Once provisioned we will create a new event hub:
https://camo.githubusercontent.com/3a69bd7abf7ce088d3dc432f82c3df298c06ff8d/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3034382d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Also, create a SAS policy for this event hub:
https://camo.githubusercontent.com/139487e3b680e708b45f05260f007a63b4196713/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3034392d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Create an Azure Function.
Now Create an Azure Function.
Go to create New Resource, type functions:
https://camo.githubusercontent.com/6e81fba9f0cc5f5aec84d44474a82ec304a1cc31/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3035302d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Select Functions App:
https://camo.githubusercontent.com/81377319bd8761a458bd6f086a22a5c9ee62bd87/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3035312d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Click create:
Now Provide the following parameters:
- App name
- Subscription
- Resource Group
- OS: Windows
- Hosting Plan: Consumption Plan
- Location: West US
- Storage: Create New
- Application Insights: ON
https://camo.githubusercontent.com/cfba5b392f88e93b5b8040e921cf9c66ac654afb/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3035332d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Use Azure Functions on the Azure Portal.
Go to the Azure portal, we will select the function and click on Add then we will select Azure Cosmos DB Trigger:
https://camo.githubusercontent.com/e1979c0bd1addd306a4ba849f25e9d23fe127587/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3035342d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
https://camo.githubusercontent.com/2f24cbfd34d514df91f282debb9150a9da4011f1/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3035352d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Now click on New and confirm this new account connection is related to our previously created Cosmos DB
https://camo.githubusercontent.com/75226e628626e0ecce021b3744c914ee025b1d17/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3035362d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
https://camo.githubusercontent.com/2fd20acf5ffd29b6c498be1b9a47290e32266bed/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3035372d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Replace with the following code:
#r "D:\home\site\wwwroot\CosmosTriggerCSharp1\bin\Microsoft.Azure.Documents.Client.dll"
#r "D:\home\site\wwwroot\CosmosTriggerCSharp1\bin\Microsoft.Azure.EventHubs.dll"
using System.Collections.Generic;
using System.Configuration;
using System.Text;
using Microsoft.Azure.Documents;
using Microsoft.Azure.EventHubs;
public static void Run(IReadOnlyList<Document> documents, TraceWriter log){
if (documents != null && documents.Count > 0) {
string connectionString = ConfigurationManager.ConnectionStrings["EventHubConnection"].ConnectionString;
log.Verbose(connectionString);
var connectionStringBuilder = new EventHubsConnectionStringBuilder(connectionString) {
EntityPath = "eventhub"
};
var client = Microsoft.Azure.EventHubs.EventHubClient.CreateFromConnectionString(connectionStringBuilder.ToString());
foreach (var doc in documents) {
string json = string.Format("{{\"iotid\":\"{0}\",\"temp\":{1}}}", doc.GetPropertyValue<string>("iotid"),
doc.GetPropertyValue<string>("temp"));
EventData data = new Microsoft.Azure.EventHubs.EventData(Encoding.UTF8.GetBytes(json));
client.SendAsync(data);
}
}
}
Now click on the function, then select platform features, then click on Kudu Console:
https://camo.githubusercontent.com/1ac5238678e57e6a266782667fe1edbbe8201b57/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3035382d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
We will be redirected to another tab in our browser to manage our Azure Function:
https://gab2018-cdmx.scm.azurewebsites.net/
Click on debug console, cmd:
https://camo.githubusercontent.com/a6c373972b77e33b53cc838a0ab21f5f5cf90c0d/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3035392d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Navigate to function directory by double clicking on wwwroot and then create a bin directory using the “+” sign.
https://camo.githubusercontent.com/07500ba8dde1757406f651592eaebfe0ca8cb777/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3036302d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
https://camo.githubusercontent.com/174ad72f40348b1c41b40027d2a2de6979d19a16/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3036312d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Go to Bin directory by double clicking on it and then add the following DLL. Get these DLL from nuget
https://camo.githubusercontent.com/ae930d68b9336ae364b585ac5298d3f64f0b3909/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3036332d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
https://camo.githubusercontent.com/2554d57695fecbb0c79372db7a29edff437bd9e1/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3036322d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Repeat this for each of the following:
- Microsoft.Azure.DocumentDB Version="1.21.0" https://www.nuget.org/packages/Microsoft.Azure.DocumentDB/Microsoft.Azure.EventHubs Version="1.1.0" https://www.nuget.org/packages/Microsoft.Azure.EventHubs/https://www.nuget.org/packages/Microsoft.Azure.Amqp/
- https://www.nuget.org/packages/Newtonsoft.Json
*Note: We can user 7zip and extract the nupkg to quickly get the DLLs.
Once we downloaded these packages go back to AppSettings Click on AppSettings
On another tab open the Event Hub and get the Connection String:
https://camo.githubusercontent.com/be7b0cbc2f66af27ce125fe0ff8eb9e09936cb7d/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3036342d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Copy the connection-primary-key:
https://camo.githubusercontent.com/2d6ca4d0bdb75c25ce36cde709139b718ffc679a/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3036352d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Now go back to our Azure Function, select Application Settings and click on add connection string:
https://camo.githubusercontent.com/f43e6f435921faf0505443542e42fa1763d43d3e/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3036362d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Then provide a Connection Name, then paste the connection string and select Connection Type as Custom
https://camo.githubusercontent.com/27d32ba92d6ae721cb2653fb1c1b277a1b8abe48/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3036372d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Now go up and click Save:
https://camo.githubusercontent.com/25e62c9e20d0a8199476a1506dd46af1e9b5bfa4/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3036382d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Now go back to our Logic App. Select "When events are available in EventHub"
https://camo.githubusercontent.com/ff15a95528bebbcaf4e7e9a552b8752320132424/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3036392d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Then provide a name and select the Event Hub.
https://camo.githubusercontent.com/79673af9e00633b04bf25670c156a6b52167901b/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3037302d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Now click Create.
Now provide the interval and frequency to check for events coming in:
https://camo.githubusercontent.com/124737ccde941db456eae9b0b297b8f4bfb3f2ae/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3037312d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Now Click new step then click add action
https://camo.githubusercontent.com/378a97f7e92c4134440ca124d116148b0c420d1d/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3037322d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
Look for "Send an email"
https://camo.githubusercontent.com/00147ac9088e2ff4f911be8f898a629ff6f7a6f8/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3037332d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67
We will need to authorize our account, Office 365 for this case,then setup the details for the email:
https://camo.githubusercontent.com/6cbd09333f94db2eb3f3b11340d7d059e7868f81/68747470733a2f2f77696b69617a7572652e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031382f30342f3037342d417a7572652d496f542d436f736d6f732d44422d776f726b73686f702e706e67