Skip to content

Instantly share code, notes, and snippets.

@ninjarobot
Created June 30, 2021 04:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ninjarobot/64f2614da7433663d836a343b1fd27d1 to your computer and use it in GitHub Desktop.
Save ninjarobot/64f2614da7433663d836a343b1fd27d1 to your computer and use it in GitHub Desktop.
Create a minimal ARM resource to use with Farmer template generation.
#r "nuget: Farmer"
open Farmer
// Give it a resource type. This is helpful the resource and handling dependencies.
let rightClickDeployments = ResourceType ("Microsoft.Hi/rightClickDeployments", "2021-06-29")
// Define the resource itself.
let minimalResource =
{ new IArmResource with
member _.JsonModel =
{| rightClickDeployments.Create (ResourceName "minimalResource", Location.EastUS) with
// Define the properties of the ARM resource here.
properties = {| hello = "world" |}
|} :> _
member _.ResourceId = rightClickDeployments.resourceId "minimalResource"
}
// Add it to a template just like any other resource.
let template =
arm {
add_resource minimalResource
}
template.Template |> Writer.toJson |> System.Console.WriteLine
@ninjarobot
Copy link
Author

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "outputs": {},
  "parameters": {},
  "resources": [
    {
      "apiVersion": "2021-06-29",
      "location": "eastus",
      "name": "minimalResource",
      "properties": {
        "hello": "world"
      },
      "type": "Microsoft.Hi/rightClickDeployments"
    }
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment