Skip to content

Instantly share code, notes, and snippets.

View forki's full-sized avatar

Steffen Forkmann forki

View GitHub Profile
group AzureFunctions
source https://api.nuget.org/v3/index.json
framework: netcoreapp3.0
storage: none
nuget FSharp.Core
nuget Microsoft.NET.Sdk.Functions
nuget Microsoft.Azure.WebJobs.Extensions.Storage
nuget Microsoft.AspNetCore.Mvc
nuget WindowsAzure.Storage
let myFun fmt =
Printf.ksprintf (fun text ->
text.Replace("1","one").Replace("2","two") // <- this is naive
) fmt
let newText = myFun "%d-%d" 1 2
printfn "%s" newText
module SocketStop
open Microsoft.Azure.WebJobs
open System.Net.Http
open FSharp.Control.Tasks.ContextInsensitive
open Microsoft.Azure.WebJobs.Extensions.Http
open Microsoft.Extensions.Logging
open Microsoft.AspNetCore.Mvc
[<FunctionName("SocketStop")>]
let rec getNextInvoiceNo (table:CloudTable) operatorID = task {
let rowKey = "invoiceno"
let query = TableOperation.Retrieve(operatorID, rowKey)
let! r = table.ExecuteAsync(query)
if r.HttpStatusCode <> 200 || isNull r.Result then
let entity = DynamicTableEntity()
entity.PartitionKey <- operatorID
entity.RowKey <- rowKey
let no = 1
let queue1 = // ..
let chunkSize = 100
[<FunctionName("Start")>]
let run([<QueueTrigger("start")>]content:string, log:ILogger) =
let t = task {
let msgs =
[1..5000]
let queue = // ..
[<FunctionName("MyFunction")>]
let run([<QueueTrigger("start")>]content:string, log:ILogger) =
let t = task {
let! _ =
[1..5000]
|> Seq.map (fun _ ->
@forki
forki / Test.fs
Last active December 12, 2018 12:54
let queue = // ..
[<FunctionName("MyFunction")>]
let run([<QueueTrigger("start")>]content:string, log:ILogger) =
let t = task { =
for i in 1 .. 5000 do
let message = CloudQueueMessage(Newtonsoft.Json.JsonConvert.SerializeObject msg)
do! queue.AddMessageAsync(message)
let allTagsEndpoint =
pipeline {
plug (fun next ctx -> task {
let txt = TagList.Encoder tags |> Encode.toString 0
ctx.SetContentType ("application/json")
return! setBodyFromString txt next ctx
})
set_header "Content-Type" "application/json"
}
get "/api/alltags" (fun next ctx -> task {
let tags = { Tags = [| { Token = "celeb" }|] }
let txt = TagList.Encoder tags |> Encode.toString 0
return! text txt next ctx
})
let getFunctionApp projectName =
match projectName with
| "RenderInvoice.fsproj" ->
""
| "TransactionHandling.fsproj" ->
"ecartransactions"
| "OCPPStatus.fsproj" ->
"ocppstatus"
| "Accounting.fsproj" ->