Skip to content

Instantly share code, notes, and snippets.

View forki's full-sized avatar

Steffen Forkmann forki

View GitHub Profile
// DEFINE PROCESSOR
type MyEventProcessorClient<'a>(blobContainer:BlobContainerClient,consumerGroup:string,connectionString:string,eventHubName:string,logger : ILogger<'a>,partitionID:string) =
inherit EventProcessorClient(blobContainer,consumerGroup,connectionString,eventHubName)
override __.ClaimOwnershipAsync(partitions:System.Collections.Generic.IEnumerable<_>, token:CancellationToken) = task {
return partitions |> Seq.filter (fun p -> p.PartitionId = partitionID)
}
let defaultRouter = router {
post "/newwish" (fun next (ctx: HttpContext) -> task {
let! message = ctx.ReadBodyFromRequestAsync()
let wish = {
OriginalMessage = message
}
let data = Newtonsoft.Json.JsonConvert.SerializeObject wish
let message = ServiceBusMessage data
do! serviceBusSender.Force().SendMessageAsync message
@forki
forki / farmer.fs
Last active December 6, 2021 20:36
containerEnvironment {
name "xmascontainers"
logAnalytics xmasLogs
add_containers [
containerApp {
name "http"
activeRevisionsMode ActiveRevisionsMode.Single
docker_image containerRegistryDomain containerRegistry "http" version
replicas 1 5
setting "ServiceBusQueueName" "wishrequests"
let inline websocket<'Data> =
FunctionComponent.Of(fun (props: {| url : string; retryTimeSpan : TimeSpan; onConnected: bool -> unit; onMessage: 'Data -> unit |}) ->
let mutable currentlyConnected = false
let mutable wasAlreadyConnected = false
let connected = Hooks.useState false
let mutable webservice = null
let connect() =
if currentlyConnected then () else
let ws = WebSocket.Create(props.url)
FunctionComponent.Of(fun (props: {| url : string; retryTimeSpan : TimeSpan; onMessage: 'Data -> unit |}) ->
let connected = Hooks.useState(false)
let wasClosed = Hooks.useState(false)
let register() =
printfn "Trying to connect"
let ws = create props.url
ws.onclose <- unbox (fun _ ->
match ws.readyState with
Deploying ARM template (please be patient, this can take a while)...
Unhandled exception. System.Exception: Azure Error: DeploymentActive
Message: Unable to edit or replace deployment 'farmer-deploy-2997': previous deployment from '6/2/2020 9:53:26 AM' is still active (expiration time is '6/9/2020 9:53:25 AM'). Please see https://aka.ms/arm-deploy for usage details.
at Farmer.Deploy.execute(String resourceGroupName, FSharpList`1 parameters, Deployment deployment)
at <StartupCode$Infrastructure>.$Program.main@() in /home/gitlab-runner/builds/e76ee70f/0/products/eCarApp/infrastructure/Program.fs:line 86
JSON parsing failed on {"sourceType":"module","body":[{"specifiers":[{"imported":{"name":"toFail","type":"Identifier"},"local":{"name":"toFail","type":"Identifier"},"type":"ImportSpecifier"},{"imported":{"name":"toText","type":"Identifier"},"local":{"name":"toText","type":"Identifier"},"type":"ImportSpecifier"},{"imported":{"name":"printf","type":"Identifier"},"local":{"name":"printf","type":"Identifier"},"type":"ImportSpecifier"},{"imported":{"name":"validateGuid","type":"Identifier"},"local":{"name":"validateGuid","type":"Identifier"},"type":"ImportSpecifier"},{"imported":{"name":"join","type":"Identifier"},"local":{"name":"join","type":"Identifier"},"type":"ImportSpecifier"}],"source":{"value":"../fable-library.2.9.0/String.js","type":"StringLiteral"},"type":"ImportDeclaration"},{"specifiers":[{"imported":{"name":"int16ToString","type":"Identifier"},"local":{"name":"int16ToString","type":"Identifier"},"type":"ImportSpecifier"},{"imported":{"name":"mapCurriedArgs","type":"Identifier"},"local":{"name":"mapCu
let frontendService (operatorID:string) = webApp {
name (operatorID + "-frontend")
docker_image frontendImage frontendStartup
app_insights_off
link_to_service_plan appServicePlanName
setting "DOCKER_ENABLE_CI" "true"
setting "DOCKER_REGISTRY_SERVER_PASSWORD" dockerPassword
setting "DOCKER_REGISTRY_SERVER_URL" containerRegistryDomain
setting "DOCKER_REGISTRY_SERVER_USERNAME" containerRegistry
let withdrawWithAudit = withdraw |> auditAs "withdraw" Auditing.fileSystem
let depositWithAudit = deposit |> auditAs "deposit" Auditing.fileSystem
while true do
let action =
Console.WriteLine()
printfn "Current balance is £%M" account.Balance
Console.Write "(d)eposit, (w)ithdraw or e(x)it: "
Console.ReadLine()
GROUP AzureFunctions
STORAGE: NONE
RESTRICTION: == netcoreapp3.0
NUGET
remote: https://api.nuget.org/v3/index.json
Braintree (4.16)
Newtonsoft.Json (>= 9.0.1)
System.Xml.XPath.XmlDocument (>= 4.3)
ExcelDataReader (3.6)
FSharp.Core (4.7)