Skip to content

Commit

Permalink
Add support for dotnet-isolated runtime. (#598)
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorvan authored Apr 23, 2021
1 parent 6b7df30 commit 7994724
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Release Notes
* Event Grid: Add ServiceBus Queue and Topic as supported destinations
* Functions: Support for 64 bits.
* Functions: Add option to use managed Key Vault
* Functions: Add support for dotnet-isolated runtime (NET5)
* KeyVault: Fix an issue with adding tags on main KeyVault builder.
* ServiceBus: update namespace validation rules to follow [Microsoft documentation](https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/resource-name-rules#microsoftservicebus)
* Storage: Add support for tables
Expand Down
9 changes: 7 additions & 2 deletions src/Farmer/Builders/Builders.Functions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ open Farmer.Arm.KeyVault
open Farmer.Arm.KeyVault.Vaults
open System

type FunctionsRuntime = DotNet | Node | Java | Python
type FunctionsRuntime = DotNet | DotNetIsolated | Node | Java | Python
type FunctionsExtensionVersion = V1 | V2 | V3

module private FunctionsConfig =
Expand Down Expand Up @@ -142,14 +142,19 @@ type FunctionsConfig =
| None ->
()

let functionsRuntime =
match this.Runtime with
| DotNetIsolated -> "dotnet-isolated"
| DotNet -> "dotnet"
| other -> (string other).ToLower()
{ Name = this.Name
ServicePlan = this.ServicePlanId
Location = location
Cors = this.Cors
Tags = this.Tags
ConnectionStrings = Map.empty
AppSettings = [
"FUNCTIONS_WORKER_RUNTIME", (string this.Runtime).ToLower()
"FUNCTIONS_WORKER_RUNTIME", functionsRuntime
"WEBSITE_NODE_DEFAULT_VERSION", "10.14.1"
"FUNCTIONS_EXTENSION_VERSION", match this.ExtensionVersion with V1 -> "~1" | V2 -> "~2" | V3 -> "~3"
"AzureWebJobsStorage", StorageAccount.getConnectionString this.StorageAccountName |> ArmExpression.Eval
Expand Down
7 changes: 7 additions & 0 deletions src/Tests/Functions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,11 @@ let tests = testList "Functions tests" [
Expect.equal secrets.[1].Value (ExpressionSecret sa.Key) "Incorrect secret value"
Expect.sequenceEqual secrets.[1].Dependencies [ vaults.resourceId "testfuncvault"; storageAccounts.resourceId "teststorage" ] "Incorrect secret dependencies"
}

test "Supports dotnet-isolated runtime" {
let f = functions { use_runtime (FunctionsRuntime.DotNetIsolated) }
let resources = (f :> IBuilder).BuildResources Location.WestEurope
let site = resources.[0] :?> Web.Site
Expect.equal site.AppSettings.["FUNCTIONS_WORKER_RUNTIME"] (LiteralSetting "dotnet-isolated") "Should use dotnet-isolated functions runtime"
}
]

0 comments on commit 7994724

Please sign in to comment.