Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for dotnet-isolated runtime. #598

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,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
14 changes: 11 additions & 3 deletions src/Farmer/Builders/Builders.Functions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ open Farmer.Arm.KeyVault
open Farmer.Arm.KeyVault.Vaults
open System

type FunctionsRuntime = DotNet | Node | Java | Python
type RuntimeKind =
| Isolated
| InProcess
type FunctionsRuntime = DotNet of RuntimeKind | Node | Java | Python
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than introducing the RuntimeKind type that is only specific to the DotNet case, it would be easier to use if DotNetIsolated is just another case altogether that represents the "dotnet-isolated" option. Then the usage remains simple like

use_runtime DotNet

or

use_runtime DotNetIsolated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's a good point, use_runtime DotNetIsolated feels better than use_runtime (DotNet Isolated).

Since the RuntimeKind was an idea from @isaacabraham maybe he wants to weigh in as well? Should we just go with a DotNetIsolated case?

Copy link
Collaborator

@ninjarobot ninjarobot Apr 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I am thinking from the perspective of use_runtime in the DSL, but I would definitely like to get perspective from @isaacabraham as well.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@isaacabraham can you please comment on this as to whether or not to break out the RuntimeKind for these?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think merging them will be better from a public API consumption point of view.

type FunctionsExtensionVersion = V1 | V2 | V3

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

let functionsRuntime =
match this.Runtime with
| DotNet Isolated -> "dotnet-isolated"
| DotNet InProcess -> "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 Expand Up @@ -280,7 +288,7 @@ type FunctionsBuilder() =
StorageAccount = derived (fun config ->
let storage = config.Name.Map (sprintf "%sstorage") |> sanitiseStorage |> ResourceName
storageAccounts.resourceId storage)
Runtime = DotNet
Runtime = DotNet InProcess
ExtensionVersion = V3
Cors = None
HTTPSOnly = false
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.DotNet RuntimeKind.Isolated) }
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"
}
]