Skip to content

Instantly share code, notes, and snippets.

Avatar

Jess Panni jesspanni

  • endjin
View GitHub Profile
View WaitForCompletion.cs
{
"name": "Wait For Completion",
"type": "WebActivity",
"dependsOn": [
{
"activity": "Start Long Running Task",
"dependencyConditions": [
"Succeeded"
]
}
View StartLongRunningActivity.json
{
"name": "Start Long Running Task",
"type": "AzureFunctionActivity",
"typeProperties": {
"functionName": "AsyncHttpFunction",
"method": "POST",
"body": {
"secondsToWait": 60
}
},
View DurableFunctionGetStatusUrl.json
{
"name": "Orchestration",
"instanceId": "66ee5d08196945aeb44c9e62ddc7b190",
"runtimeStatus": "Running",
"input": 10,
"customStatus": null,
"output": null,
"createdTime": "2019-09-17T16:10:17Z",
"lastUpdatedTime": "2019-09-17T16:10:18Z"
}
View DurableFunctionStarterResponse.json
{
"id": "66ee5d08196874aeb99c9e62ddc7b190",
"statusQueryGetUri": "https://asynchttpfunction.azurewebsites.net/runtime/webhooks/durabletask/instances/66ee5d08196945aeb44c9e62ddc7b190?taskHub=Orchestration&connection=Storage&code=FSVfJyGODSeKHPO0cM8Po9e1jMT7MghVMGuJqTaGTN56E1RUHnlVJg==",
"sendEventPostUri": "https://asynchttpfunction.azurewebsites.net/runtime/webhooks/durabletask/instances/66ee5d08196945aeb44c9e62ddc7b190/raiseEvent/{eventName}?taskHub=Orchestration&connection=Storage&code=FSVfJyGODSeKHPO0cM8Po9e1jMT7MghVMGuJqTaGTN56E1RUHnlVJg==",
"terminatePostUri": "https://asynchttpfunction.azurewebsites.net/runtime/webhooks/durabletask/instances/66ee5d08196945aeb44c9e62ddc7b190/terminate?reason={text}&taskHub=Orchestration&connection=Storage&code=FSVfJyGODSeKHPO0cM8Po9e1jMT7MghVMGuJqTaGTN56E1RUHnlVJg==",
"rewindPostUri": "https://asynchttpfunction.azurewebsites.net/runtime/webhooks/durabletask/instances/66ee5d08196945aeb44c9e62ddc7b190/rewind?reason={text}&taskHub=Orchestration&connectio
View ProcessingFunction.cs
[FunctionName(nameof(Function1.LongRunningOperation))]
public Task LongRunningOperation([ActivityTrigger]int secondsToWait, ILogger log)
{
log.LogInformation($"Doing something really interesting for {secondsToWait} seconds");
return Task.Delay(TimeSpan.FromSeconds(secondsToWait));
}
View StartFunction.cs
[FunctionName("AsyncHttpFunction")]
public static async Task<IActionResult> RunAsync(
[HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req,
[OrchestrationClient​] IDurableOrchestrationClient starter,
ILogger log)
{
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
string instanceId = await starter.StartNewAsync("Orchestration", (int)(data.secondsToWait ?? 60)).ConfigureAwait(false);
View Orchestration.cs
[FunctionName("Orchestration")]
public async Task Run(
[OrchestrationTrigger]IDurableOrchestrationContext context,
ILogger log)
{
int secondsToWait = context.GetInput<int>();
await context.CallActivityAsync(nameof(Function1.LongRunningOperation), secondsToWait);
}
@jesspanni
jesspanni / input.csv
Created Apr 25, 2019
adf-snowflake-sample-data
View input.csv
2400001 132304 4818 1 10.00 13363.00 0.03 0.02 N O 2016-06-30 2016-06-25 2016-07-17 NONE SHIP egular dolphins1
2400001 24513 2020 2 14.00 20125.14 0.04 0.03 R F 2016-05-01 2016-05-05 2016-05-10 COLLECT COD SHIP es wake quickly bold packages. sly idea1
2400001 175232 7750 3 18.00 23530.14 0.01 0.07 N O 2016-07-20 2016-05-06 2016-08-02 NONE REG AIR ic deposits. carefully blithe packages1
2400001 119658 4681 4 2.00 3355.30 0.09 0.08 A F 2016-05-15 2016-06-17 2016-05-28 DELIVER IN PERSON REG AIR hinder slyly quickly silent deposi1
2400001 89532 4549 5 13.00 19779.89 0.07 0.03 A F 2016-04-08 2016-06-27 2016-04-12 COLLECT COD REG AIR ges believe slyly furiously bold courts1
2400002 188783 3820 1 14.00 26204.92 0.09 0.01 R F 2015-09-13 2015-09-25 2015-10-06 TAKE BACK RETURN MAIL around the slyly ironi1
2400002 67505 5024 2 1.00 1472.50 0.00 0.04 R F 2015-11-14 2015-10-30 2015-12-07 COLLECT COD REG AIR ding depen1
2400002 142916 2917 3 7.00 13712.37 0.03 0.04 R F 2015-08-29 2015-09-29 2015-09-17 NONE MAIL sits are
@jesspanni
jesspanni / adf-snowflake.sql
Last active Apr 25, 2019
SnowflakeADFConnectorDatabaseSetup
View adf-snowflake.sql
CREATE DATABASE IF NOT EXISTS "ADF-DB";
USE DATABASE "ADF-DB";
CREATE SCHEMA IF NOT EXISTS "SALES";
USE SCHEMA "SALES";
CREATE TABLE IF NOT EXISTS LINEITEM (
L_ORDERKEY NUMBER(38,0),
@jesspanni
jesspanni / UnloadFunction.cs
Created Apr 24, 2019
SnowflakeUnloadFunction
View UnloadFunction.cs
public static async Task<HttpResponseMessage> Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "v1/unload")]
HttpRequestMessage req,
ILogger logger,
ExecutionContext context)
{
ServiceProvider serviceProvider = Initializer.Initialize(context);
string body = await req.Content.ReadAsStringAsync().ConfigureAwait(false);
UnloadCommand command = JsonConvert.DeserializeObject<UnloadCommand>(body);