Skip to content

Instantly share code, notes, and snippets.

View ThomasPe's full-sized avatar

Thomas Pentenrieder ThomasPe

View GitHub Profile
@ThomasPe
ThomasPe / index.js
Created October 2, 2018 11:39
Blank JavaScript Azure Function
module.exports = async function (context, req) {
context.log('JavaScript HTTP trigger function processed a request.');
context.res = {
status: 200,
body: "Result message"
};
};
@ThomasPe
ThomasPe / index.js
Last active October 3, 2018 11:04
Create | Azure Functions + NodeJs + Table Storage
// Reference to the Azure Storage SDK
const azure = require('azure-storage');
// Reference to the uuid package which helps us to create
// unique identifiers for our PartitionKey
const uuid = require('uuid/v1');
// The TableService is used to send requests to the database
const tableService = azure.createTableService();
//
const tableName = "mytable";
@ThomasPe
ThomasPe / index.js
Created October 3, 2018 11:05
Update | Azure Functions + NodeJs + Table Storage
const azure = require('azure-storage');
const tableService = azure.createTableService();
const tableName = "mytable";
module.exports = function (context, req) {
context.log('Start ItemUpdate');
if (req.body) {
@ThomasPe
ThomasPe / index.js
Created October 3, 2018 11:07
Delete | Azure Functions + NodeJs + Table Storage
const azure = require('azure-storage');
const tableService = azure.createTableService();
const tableName = "mytable";
module.exports = function (context, req) {
context.log('Start ItemDelete');
const id = req.query.id;
if (id) {
@ThomasPe
ThomasPe / app.js
Created September 7, 2020 15:00
IoT Edge Identity Translation Module Sample
'use strict';
const Transport = require('azure-iot-device-mqtt').Mqtt;
const ModuleClient = require('azure-iot-device').ModuleClient;
const Message = require('azure-iot-device').Message;
const DeviceClient = require('azure-iot-device').Client;
let simulatedTemperatureClient;
ModuleClient.fromEnvironment(Transport, function (err, moduleClient) {
@ThomasPe
ThomasPe / deployment.template.json
Created September 8, 2020 07:39
deployment.template.json Modules
"modules": {
"IdentityTranslationModule": {
"version": "1.0",
"type": "docker",
"status": "running",
"restartPolicy": "always",
"settings": {
"image": "${MODULES.IdentityTranslationModule}",
"createOptions": {}
},
@ThomasPe
ThomasPe / deployment.template.json
Created September 8, 2020 07:47
deployment.template.json $edgeHub
"$edgeHub": {
"properties.desired": {
"schemaVersion": "1.0",
"routes": {
"IdentityTranslationModuleToIoTHub": "FROM /messages/modules/IdentityTranslationModule/outputs/* INTO $upstream",
"sensorToIdentityTranslationModule": "FROM /messages/modules/SimulatedTemperatureSensor/outputs/temperatureOutput INTO BrokeredEndpoint(\"/modules/IdentityTranslationModule/inputs/input1\")"
},
"storeAndForwardConfiguration": {
"timeToLiveSecs": 7200
}
@ThomasPe
ThomasPe / deployment.template.json
Created September 8, 2020 07:50
deployment.template.json Full
{
"$schema-template": "2.0.0",
"modulesContent": {
"$edgeAgent": {
"properties.desired": {
"schemaVersion": "1.0",
"runtime": {
"type": "docker",
"settings": {
"minDockerVersion": "v1.25",
@ThomasPe
ThomasPe / deployment.template.json
Created September 16, 2020 12:52
Module Deployment Configuration for using Bluetooth / BLE in Docker Container
"modules": {
"BLEModule": {
"version": "1.0",
"type": "docker",
"status": "running",
"restartPolicy": "always",
"settings": {
"image": "${MODULES.BLEModule}",
"createOptions": {
"NetworkingConfig": {
@ThomasPe
ThomasPe / app.js
Created September 16, 2020 13:41
Reading Ruuvi Tag messages in IoT Edge
Client.fromEnvironment(Transport, function (err, client) {
if (err) {
throw err;
} else {
client.on('error', function (err) {
throw err;
});
// connect to the Edge instance
client.open(function (err) {