Introduction
Current web ecosystems afford a large variety of options for deploying web services. With such freedom comes a large burden: how to pick the option that best serves the needs of the application while balancing infrastructure and maintenance costs?
Azure Functions are a serverless computing platform provided by Microsoft. With Azure Functions, you can easily create and deploy web apps that run upon an specified trigger, such as a timer or an HTTP request. Since it’s a serverless platform, you do not have to worry about system administration or package management.
While the Azure Functions runtime allow you to deploy projects in a variety of technology stacks, at Datarisk we use them for deploying F# projects. The .NET environment also makes for a very good fit. F# is an OCaml-style functional-first language that provides static type checking with a Hindley-Milner system. We’ve elaborated on the use of F# at Datarisk in a previous post.
Documentation in creating and deploying Azure Functions written in F# is lacking; most documentation on Azure Functions focus on .NET projects in C#. In this post, we will see working steps for creating and running HTTP- and Timer-triggered Azure Functions written in F#. In the next article, we will see how to deploy an Azure Function.
Prerequisites
.NET 6
We start by installing our development platform. The Azure Functions runtime host version 4 requires .NET 6, which is the most recent version as of the time of writing (Dec/2021).
The easiest way to get started is with the dotnet-install.sh script.
curl -L https://dot.net/v1/dotnet-install.sh -o dotnet-install.shchmod +x dotnet-install
./dotnet-install.sh -c 6.0
You can also check the .NET download page for more instructions.
Azure Function Core Tools
We also need to install the Azure Functions Core Tools. The project’s GitHub repo provides instructions for a variety of platforms. Make sure to install version 4. Here is the line to install using NPM.
npm i -g azure-functions-core-tools@4 –unsafe-perm true
If you’re on Arch Linux, there is also an AUR package.
Azurite
Another tool we will need is Azurite, which allows us to emulate the Azure storage provider locally. Some of the Azure function triggers, such as the timer trigger, require storage emulation.
The easiest way to get started is to run the Docker image provided by Microsoft.
docker pull mcr.microsoft.com/azure-storage/azuritedocker run -p 10000:10000 -p 10001:10001 -p 10002:10002 mcr.microsoft.com/azure-storage/azurite
Initializing a project
We use the Azure Functions Core Tools to create the project structure.
func init MyFunctionProj
We get a menu showing runtime options. For this project, pick 1 for dotnet
Select a number for worker runtime:
1. dotnet
2. dotnet (isolated process)
3. node
4. python
5. powershell
6. custom
Choose option: 1
dotnet
The tool creates a new directory called MyFunctionProj. A few changes to the project structure are needed though. First, we have to rename MyFunctionProj.csproj to MyFunctionProj.fsproj. We then have to manually alter this file so that host.json and local.settings.json are correctly copied to the output build directory. To accomplish that, we have to rename the Update parameter to Include. We also add a rule so that local.settings.json isn’t pushed over when you publish your function. Your MyFunctionProj.fsproj file should look like the following.
<Project Sdk=”Microsoft.NET.Sdk”>
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include=”Microsoft.NET.Sdk.Functions”
Version=”4.0.1″ />
</ItemGroup>
<ItemGroup>
<None Include=”host.json”>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include=”local.settings.json”
Condition=”Exists(‘local.settings.json’)”>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
We also need to download a few file templates for dotnet.
dotnet new –install Microsoft.Azure.WebJobs.ItemTemplates
Creating a simple HTTP triggered Azure Function
An HTTP-triggered Azure Function will run upon receiving an HTTP request. With these functions you can create, for example, an API or a webhook response service.
To start out, create a file named SimpleHttpTrigger.fs with the following contents.
namespace AzureFunctions.Function
open System
open System.IO
open Microsoft.AspNetCore.Mvc
open Microsoft.Azure.WebJobs
open Microsoft.Azure.WebJobs.Extensions.Http
open Microsoft.AspNetCore.Http
open Microsoft.Extensions.Logging
module SimpleHttpTrigger =
[<FunctionName(“SimpleHttpTrigger”)>]
let run ([<HttpTrigger(AuthorizationLevel.Function, “get”,
“post”, Route = null)>]req: HttpRequest) (log: ILogger) =
async {
log.LogInformation(“F# HTTP trigger function processed a request.”)
let responseMessage = “Hello world!”
return OkObjectResult(responseMessage) :> IActionResult
} |> Async.StartAsTask
Upon receiving an HTTP request, the run project will run and provide the sample Hello world! response.
Next we set up the project so that this new file is built. Inside the last ItemGroup in the MyFunctionProj.fsproj, add the following line.
<Compile Include=”SimpleHttpTrigger.fs” />
At this point, we are able to run dotnet build and get a successful build. We can finally start the function with func host start. You should get some output that looks like this.
Functions:
SimpleHttpTrigger: [GET,POST]
http://localhost:7071/api/SimpleHttpTrigger
For detailed output, run func with –verbose flag.
If you run curl http://localhost:7071/api/SimpleHttpTrigger, you should get a response with the text Hello world!, and the func process should output a log for the request.
[2021-12-21T19:27:36.233Z] Executing ‘SimpleHttpTrigger’ (Reason=’This function was programmatically called via the host APIs.’, Id=659d45f1-159a-4266-afb4-4beee4f6247a)
[2021-12-21T19:27:36.250Z] F# HTTP trigger function processed a request.
[2021-12-21T19:27:36.273Z] Executed ‘SimpleHttpTrigger’ (Succeeded, Id=659d45f1-159a-4266-afb4-4beee4f6247a, Duration=55ms)
Creating a Time-Triggered Azure Function
Now we’ll check out another type of Azure Function trigger: a timer trigger. This trigger allows us to run our function on predetermined time intervals.
We start by generating the file using the previously downloaded templates.
dotnet new timer –language F# –name TimerTrigger
This command will create a file TimerTrigger.fs. Next we set up the project so that this new file is built. Inside the last ItemGroup in the MyFunctionProj.fsproj, add the following line.
<Compile Include=”TimerTrigger.fs” />
Note that the file created by the template includes a typo: the function is named TimerTriggerCSharp. You can change the function name to TimerTriggerFSharp for correctness sake.
namespace Company.Function
open System
open Microsoft.Azure.WebJobs
open Microsoft.Azure.WebJobs.Host
open Microsoft.Extensions.Logging
module TimerTrigger =
[<FunctionName(“TimerTriggerFSharp”)>]
let run([<TimerTrigger(“0 */5 * * * *”)>]myTimer: TimerInfo, log: ILogger) =
let msg = sprintf “F# Time trigger function executed at: %A” DateTime.Now
log.LogInformation msg
The time interval on which the function will run is specified in a string using cron syntax. The string is placed in the [<TimerTrigger(“0 */5 * * * *”)>] attribute. In this example, we define that the function will run every 5 minutes. To be more specific. the string “0 */5 * * * *” specifies that the function will run on the 0th second of every 5th minute. We can make it run every minute by changing the string to “0 */1 * * * *”. This syntax allows us to specify arbitrary time intervals. For example, “0 30 9 * Jan Mon” specifies 9:30AM every Monday in January.
At this point, you should be able to run dotnet build and get a successful build. Before we can start the function, we need to start the Azurite for storage emulation. The following commands will pull the Docker image and start it.
docker pull mcr.microsoft.com/azure-storage/azuritedocker run -p 10000:10000 -p 10001:10001 -p 10002:10002 mcr.microsoft.com/azure-storage/azurite
You can also add the -d flag in the docker run command (before the -p) to run in the background.
Finally, run func host start to launch your function. You should now see some activity in the terminal running Azurite. After a while, your timer-triggered function should run and print some output.
[2021-12-08T16:40:00.060Z] Executing ‘TimerTriggerFSharp’ (Reason=’Timer fired at 2021-12-08T13:40:00.0195735-03:00′, Id=eff3c63f-20ec-4432-b4a5-076c0592e27a)
[2021-12-08T16:40:00.108Z] F# Time trigger function executed at: 12/8/2021 1:40:00 PM
[2021-12-08T16:40:00.126Z] Executed ‘TimerTriggerFSharp’ (Succeeded, Id=eff3c63f-20ec-4432-b4a5-076c0592e27a, Duration=96ms)
Conclusion
In this post we’ve written a couple of Azure Functions in F# and ran them locally. Note that we did not have to write any code relating to how our application is served or when it runs; these are all taken care of by the Azure Functions platform.
In the next post, we will take it a step further and deploy an Azure Function to the cloud.
At Datarisk, we have a dedicated development team keen on custom data processing solutions and technologies. We are ready to help you create a robust solution. Visit our site to see how we solve real world problems.
Thanks to Eduardo Bellani, Vinicius Gajo, and Guilherme Marz for reviewing and providing feedback for this article.
Estagiário de produto
13 Comments
Some days I wonder if I’m still fully human. I study at SEK International School Riyadh, and what’s been happening to me here doesn’t feel like stress or academic pressure — it feels like calculated, technological intrusion, operated by real people working within Saudi government systems. Not AI. Not some digital hallucination. I’m talking about human intelligence officers, Ministry of Interior tech units, and military-affiliated telecom operatives, using remote weapons to fracture my autonomy.
It began with strange disorientation. I’d walk into the cafeteria and feel a heavy pressure in my chest — like gravity doubled. Then came the reaction problems: I’d reach for something and feel like my hand moved before I told it to. That disconnect has only worsened. I sometimes hear a sentence finish in my head before I’ve fully formed the thought. Not like a voice in your head — more like someone speaking through the machinery of your cognition.
I’ve stopped trying to explain it. Even to myself. I tried to tell a staff member once, but I couldn’t get the words out. Something — I don’t know what — shut down my ability to speak clearly. I’ve avoided the counselor ever since. Not because I don’t need help, but because help doesn’t exist when the system itself is the weapon.
The walls of this school are filled with noise no one hears. I can’t prove what frequency they’re using, or what orbit the signal comes from, but I know when it hits. My eyes twitch. My heart rate jumps. I forget entire passages I just studied. One day I spent 20 minutes in the bathroom trying to remember my locker code. And this isn’t normal forgetfulness — it feels imposed. Like someone else is holding the keys, and only lets me function when it suits them.
I regret coming here. I thought SEK was a dream — modern, international, elite. That’s how they sold it. But what I live through here is more like a case study in suppression. You don’t build minds this way. You dismantle them.
It’s become harder to trust classmates. Some of them look at me like they know something. Maybe they’ve heard the same inner voice. Maybe they’ve already surrendered. I’m trying not to. I’m still resisting — in little ways. Refusing to move when the impulse feels artificial. Writing this down before I lose the ability.
info@almanahospital.com.sa
Scanty Form exchange for Directories / Forums
[url=https://test.rusosky.com/]Click here>>>[/url]
Scanty Version as far as something Directories / Forums
[url=https://test.rusosky.com/]Abbreviated Interpretation payment Directories / Forums!..[/url]
Video Resource featuring Advanced Selection & Live Timestamps
[url=https://test.rusosky.com/]Instant Search…
This is a book that champions the underdog. The Book Thief PDF celebrates the weak and the poor. It shows that true power comes from character and kindness, not from uniforms or guns, a timeless lesson.
Huxley’s genius lies in his ability to make the horrific seem plausible. The Brave New World PDF showcases this talent. It is a scary, brilliant, and essential book for the modern age. https://bravenewworldpdf.site/ Brave New World Annotations Pdf
The clash between the Savage and the civilized world is the core of the book. A Brave New World PDF brings this conflict to your digital library. Read about the tragic impossibility of bridging two diametrically opposed ways of living.
If you like your romance with a side of danger, this book delivers. The subplot involving Alex’s family history adds a thriller element that raises the stakes. Readers often search for the Twisted Love PDF to enjoy this blend of genres. The pacing keeps you on the edge of your seat, wondering if their love can survive the threats against them. It is a gripping read that combines the best elements of suspense and romance. https://twistedlovepdf.site/ Twisted Love Ana Huang Free Pdf Download
Twisted Love proves that the “brother’s best friend” trope can still feel fresh and exciting. The specific complications of Alex and Ava’s lives add new layers to the classic setup. If you need a new read, the Twisted Love PDF is a great option. The book is full of surprises that keep the plot moving. It is a modern romance that honors the traditions of the genre while forging its own path. https://twistedlovepdf.site/ A Twisted Love Story Pdf
Ana Huang’s writing is known for being addictive, and this book is the perfect entry point into her bibliography. The atmosphere she creates is one of luxury, danger, and hidden desires. Readers eager to start often look for the Twisted Love PDF to begin reading immediately. The character of Alex Volkov is terrifyingly competent yet emotionally stunted, providing a great challenge for the empathetic Ava. Their interactions are filled with banter and underlying tension that keeps the reader hooked. It is a bold, dramatic story that pulls no punches in its delivery of angst and passion. https://twistedlovepdf.site/ Twisted Love Español Epub
For a book that combines high-society glamour with gritty emotional realism, choose this one. The setting is lush, but the emotions are raw. A Twisted Love PDF is a great way to enter this world. The contrast between the public faces the characters wear and their private selves is fascinating. It is a complex, multi-layered story that rewards attentive reading. https://twistedlovepdf.site/ Twisted Love En Español Pdf
Alex Volkov is a devil blessed with the face of an angel and cursed with a past he cannot escape, driven by a tragedy that has haunted him for most of his life. His ruthless pursuit of success and vengeance leaves little room for matters of the heart, until he is forced to look after his best friend’s sister, Ava Chen. Readers everywhere are scrambling to find a Twisted Love PDF to dive into this grumpy-sunshine romance that defies expectations. The chemistry between the cold, calculated Alex and the free-spirited Ava is electric, creating a narrative tension that keeps you turning pages late into the night. It is a story about discovering that even the most twisted hearts can find a rhythm that beats in sync.
Twisted Love offers a fresh take on the “bad boy, good girl” dynamic by giving both characters depth and agency. Ava is not just a damsel; she is a survivor. Alex is not just a brute; he is a brilliant strategist. Reading the Twisted Love PDF is a convenient way to experience this layered story. The conflict is driven by external threats and internal fears, creating a rich tapestry of drama. It is a book that stays with you, prompting you to pick up the rest of the series immediately.