In this exercise, you’ll:
Create an F# console application using the .NET SDK and add the Farmer package in an empty directory:
dotnet new console -lang F#
dotnet add package Farmer
Farmer also has a .NET template to get started even more quickly!
Open Program.fs
and delete all the contents.
In Farmer, resources are defined using special code blocks that look somewhat json-esque, known as a “builder”. In these builders you can quickly and easily configure a resource using special keywords, but unlike json you also have edit-time safety.
Create a Farmer web application using the webApp { }
builder:
open Farmer
open Farmer.Builders
let myWebApp = webApp {
name "yourFirstFarmerApp"
}
Create an ARM template deployment object, before setting the location for the overall resource group and adding the web app into it.
let deployment = arm {
location Location.NorthEurope
add_resource myWebApp
}
Now you need to generate the ARM template from the deployment object to an ARM json file.
Add the following code:
deployment
|> Writer.quickWrite "myFirstTemplate"
Run the application:
dotnet run
You should notice that the file myFirstTemplate.json
has been created.
The generated ARM template contains the following resources:
The resources will be correctly configured with the appropriate dependencies set.
open Farmer
open Farmer.Builders
let myWebApp = webApp {
name "yourFirstFarmerApp"
}
let deployment = arm {
location Location.NorthEurope
add_resource myWebApp
}
deployment
|> Writer.quickWrite "myFirstTemplate"