Skip to content

Deploying and Configuration

Ivan Emilov edited this page Apr 4, 2018 · 10 revisions

Table of contents

Deploying and Configuration

Once you got your azure free account, you can start deploying and configuring the required resources:

Note: before starting keep in mind that you should create all resources in the same geographical region in order to save outband costs and to use the bandwith as effective as possible!

Create Resource Group:

A resource group is a container for all your resources which are to be deployed in the further steps: How to create resource group?

Create Storage Account:

How to create storage account?

What is the storage account for?

  • store alarms and sent notifications in table storage
  • store telemetry data, device logs and platform logs in blob container

Once you have successfully deployed the storage account within your azure subscription you can start with configuring it:

Step 1 Create Alarm Table

Open your storage account resource in the azure portal --> go to tables --> go to the plus symbol and create table. Give a name for the table where the application will store all alarms (for example "alarms")

Step 2 Create Sent Notifications Table

Create another table where the application will store all sent notifications for statistic purposes. More details about azure table storage

Step 3 Create Container Platform Logs

From the portal again --> go to blobs --> go to plus symbol and create container with access level private for storing all the platform logs (example "platform-logs")

Step 4 Create Container Device Logs

Create container for device logs(for example "devicelogs")

Step 5 Create Endpoint for Telemetry Data

Create container for storing of all sensor data coming from the objects/devices (example name telemetry). Create a file within this container which will hold all telemetry data ( example name telemetry.json)

Step 6 Store Account Key

Store the first key from the example below - you will need it for the application settings

In order to simplify the future work with the storage accounts it is recommended to use the azure storage explorer

Azure IoT Hub:

How to create an IoT Hub?

Pricing - in order to get impression of the platform would be enough to choose free tier 8000 messages per day.

What are the consumer groups for? Distributing the load accross the services which are responsible for processing the incomming messages:

  • 1st consumergroup: used the service which listens to live events
  • 2nd consumer group: used by the services which triggers rules events

Step 7 Create Consumer Groupes

Add 2 consumer groups: what is consumer group? Once you created the iot hub go to iothub resource via the portal --> endpoints --> Built-in endpoints --> events --> add the name of the consumer group for the RulesEngine (for example rules) under 'consumer groups' and store it. Repeat this action and create another consumer group fo the livedata.

Step 8 Activate File Upload

see example here go to the File Upload --> click on the field Azure Storage container and choose the storage account name together with the container name for your devicelogs created in Step 4 --> save the settings

See another example here!

Step 9 Store Connection String for IoT Hub

You will need this connection string for the application settings.

Find the connection string

Azure Cosmos DB:

How to install Azure Cosmos DB?

Note: you can create this database using the description in the provided link. Comapared to the example you should choose mongo DB as API and not SQL!

What is the MongoDB for?

  • store users documents in extra collection
  • store objects/devices/sensors realtions in extra collection
  • store rules documents in extra collection

Once you have successfully deployed the resource within your azure subscription you can start with configuring it:

Step 10 Create Database

Go to created resource via the portal --> go to collections and click on browse --> click on add Database --> give a name of your database --> click OK

Step 11 Create Collections

After successfully creating the database --> go to add collection --> choose the created database in the previous step --> give a collection name (for example users) --> choose storage capacity 10GB and put 400 in the throughput field to save costs. You should execute this step 3 times in order to create 3 collections (users, devices, rules)

Step 12 Get Mongo Db Connection String

You will need this connection string for the application settings. In this case you should add the created database name (Step 10) to the connection string. The final connection string should look like the example below: The capital letters in the example show the position wehere to place the database name:


Find the connection string

Note: you can also use your own MongoDb database, for example on premise if you have your own datacenter.

Azure Sendgrid:

How to create send grid within Azure?

Pricing - choose free tier 2500 mails/month

What is the SendGrid for? Sendgrid is a third party service for sending emails.

Once you have successfully deployed the sendgrid resource you only need to generate and store the API key as described in the provided example

Azure API App

What is the API APP for?

This is the most important resource which you will deploy the code to: go to azure portal and click create resource --> write API App in the search field --> click on create --> enter the name of the your application --> choose your subscription and the resource group created in the beginning --> choose free application service plan F1, choose the same location as the other components and give it a name --> leave Applications insights off and create the resource.

Once you have successfully deployed the API app within your azure subscription you can start with configuring the parameter:

Step 13 Configure Application Parameters

Go to the created API app resource --> Settings --> Application settings and enter the following parameters step by step .

Note: all parameters in left fields in bold (keys) font should be named exactly as the description below. The values are either free to choose or depends on the names created on the prvious steps


  • node version: WEBSITE_NODE_DEFAULT_VERSION: 8.9.3
  • token issuer: issuer: (free to choose)
  • shared secret: sharedSecret: cfee02d6-c137-11e5-8d731f2d1e2e67df-welcome-on-board-goiot-true (free to choose)
  • endpoint IoT Hub: endpointIoTHuB: IoT hub connection string from Step 9
  • enter consumer 1st group: consumergroupRules: the consumer group for rules created in Step 7
  • enter 2nd consumer group: consumergroupLiveData: the consumer group for live data created also in Step 7
  • connection database: consumergroupLiveData: mongoDb connection string created in Step 12
  • users collection: user.collection: users collection created in Step 11
  • devices collection: devices.collection: devices collection created in Step 11
  • rules collection: rules.collection: rules collection created in Step 11
  • storage account name: storageAccountName: name of the created storage account at the beginning
  • storage account key: storageAccountKey: the account key from Step 6
  • table alarm: tableName: tabale name for alarms created in Step 1
  • table sentNotifications: sentNotifications: tabale name created in Step 2
  • container platform logs: containerNameLogs: container name created in Step 3
  • file platform logs: fileNameLogs: platform (free to choose)
  • container device logs: containerNameDeviceLogs: devicelogs container name created in Step 4
  • sendgrid: sendgrid: enter the API key created through the sendgrid environment Azure sendgrid
  • sender email: fromField: enter an arbitary sender email address (free to choose)
  • email subject: mailSubject: enter an arbitary email subject (for example Alert)
  • email subject: mailTemplate: enter an arbitary email template, for example Hi, a new alert is, (free to choose)
  • email text: mailText: enter an arbityry text(example: Please pay attention on the following object:)
  • email signature: mailSignature: arbitary email signature (example: Thanks for choosing our team, The Team Name)
  • telemetry container: containerTelemetry: container name created in Step 5
  • telemetry file: fileTelemetry: enter filename for telemetry data (for example telemetry.json)
  • set file name device logs: fileNameDeviceLogs: enter filename ending for device logs (for example /logs.txt)
  • telemetry CSV: fileTelemetryCSV: enter filename for CSV telemetry data (for example telemetry.csv)
  • initial password: initialAdminPassword: enter an arbitrary password for the intial user after deployment (for example 46ag52c8z9)

Note: Please be aware that the RulesEngine together with the StoreTelemetry service are running as continious CRON jobs within the application. In general or in production The "Always on options" within the Application settings should be activated if you have continious running WebJobs like in this case. If you want to activate it, you should upgrade the App Service plan to Standrard. In the case of using the free plan as recommended in this description the WebJobs will go from time to time down after the application has been idle.

Within this application the WebJob will be deployed automatic but if you want to get a better understanding of the WebJobs, please take a look here

Once you entered the final apllication setting you are ready to deploy your code. Before doing that, one additional step should be executed:

Step 14 Create Local Git for the Azure API App**

  • Go to the API app resource via the portal
  • Under Deployment, cick Deployment credentials The Deployment credentials blade provides FTP credential settings that you need in order to deploy your site via FTP. Since Git and FTP can't authenticate using your Azure account information, you will be creating a new username and password that Git and FTP can use when deploying code to your Azure subscriptions
  • In the FTP/deployment username textbox, enter the username that you want to use
  • In the password and Confirm password textboxes, enter the password that you want to use
  • At the top of the blade, to save your changes, click Save
  • On the left side menu, click on Deployment Options
  • On the Deployment source blade, click Source, and the click Local Git Repository
  • Click OK to save the changes
  • On the left menu go to Overview and store the Git Clone Url. The url should looke like:
You can’t perform that action at this time.