This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ErrorActionPreference = "Stop" | |
$global:_subscriptionId = $null | |
$global:_workload = $null | |
$global:_workloadCore = $null | |
$global:_regionCode = $null | |
$global:_keyvault_name = $null | |
$global:_storageAccount = $null | |
$global:_storageContext = $null | |
$global:_storageAccountConnectionString = $null | |
$global:_logicAppJson = $null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var connString = "Server=timescaledb;Port=5432;Database=postgres;User Id=postgres;Password=PASSWORD;"; | |
using (var conn = new NpgsqlConnection(connString)) | |
{ | |
string sql = $"insert into Table_001 VALUES ('{p.TimeStamp}',{p.IsAirConditionerOn},{p.Temperature},'{p.TagKey}')"; | |
await conn.OpenAsync(); | |
using (var cmd = new NpgsqlCommand(sql, conn)) | |
{ | |
await cmd.ExecuteNonQueryAsync(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE IF NOT EXISTS table_001 | |
( | |
"Timestamp" timestamp with time zone not null, | |
IsAirConditionerOn smallint not null, | |
Temperature decimal not null, | |
tagkey varchar not null | |
); | |
ALTER TABLE table_001 OWNER TO postgres; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"TimescaleDB": { | |
"version": "1.0", | |
"type": "docker", | |
"status": "running", | |
"restartPolicy": "always", | |
"settings": { | |
"image": "${MODULES.TimescaleDb.debug}", | |
"createOptions": { | |
"HostConfig": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM timescale/timescaledb:latest-pg11 | |
ENV POSTGRES_USER postgres | |
ENV POSTGRES_DB postgres | |
ENV POSTGRES_PASSWORD m5asuFHqBE | |
COPY init.sql /docker-entrypoint-initdb.d/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This method is called whenever the module is sent a message from the EdgeHub. It just pipe the messages without any change.It prints all the incoming messages. | |
static async Task<MessageResponse> PipeMessage(Message message, object userContext) { | |
int counterValue=Interlocked.Increment(ref _counter); | |
var moduleClient=userContext as ModuleClient; | |
byte[] messageBytes=message.GetBytes(); | |
string messageString=Encoding.UTF8.GetString(messageBytes); | |
if (!string.IsNullOrEmpty(messageString)) { | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ModuleClient ioTHubModuleClient; | |
var connectionSettings = new MqttTransportSettings(TransportType.Mqtt_Tcp_Only); | |
ITransportSettings[] settings = { connectionSettings }; | |
ioTHubModuleClient = await ModuleClient.CreateFromEnvironmentAsync(); | |
await ioTHubModuleClient.OpenAsync(); // Open a connection to the Edge runtime | |
// Register callback to be called when a message is received by the module | |
await ioTHubModuleClient.SetInputMessageHandlerAsync("input1", PipeMessage, ioTHubModuleClient); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var connectionSettings = new MqttTransportSettings(TransportType.Mqtt_Tcp_Only); // setup connection to hubs MQTT broker | |
ITransportSettings[] settings = { connectionSettings }; | |
ioTHubModuleClient = await ModuleClient.CreateFromEnvironmentAsync(); // inbuilt SDK magic to connect using environment variables | |
await ioTHubModuleClient.OpenAsync(); // connect | |
var chance = new Chance(42); // random data generator | |
var payload = chance.Object<Payload>(); | |
var currentTemp = 20d; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Payload | |
{ | |
public DateTime TimeStamp { get; set; } | |
public bool IsAirConditionerOn { get; set; } | |
public double Temperature { get; set; } | |
public string TagKey { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fact] | |
public async Task Will_create_sales_order_in_single_changeset() | |
{ | |
string d365FoServiceUrl = Environment.GetEnvironmentVariable("D365FO.ServiceUrl", EnvironmentVariableTarget.User); | |
string clientId = Environment.GetEnvironmentVariable("D365FO.AppClientId", EnvironmentVariableTarget.User); | |
string username = Environment.GetEnvironmentVariable("D365FO.Username", EnvironmentVariableTarget.User); | |
string password = Environment.GetEnvironmentVariable("D365FO.Password", EnvironmentVariableTarget.User); | |
string tenantId = Environment.GetEnvironmentVariable("TenantId", EnvironmentVariableTarget.User); | |
var token = Authenticator.GetAuthTokenForAadNativeApp(username, password, tenantId, d365FoServiceUrl, clientId); |