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 Linux runtime on a web app slot #75

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 15 additions & 1 deletion src/Farmer/Builders/Builders.WebApp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,21 @@ type SlotConfig =
|AspNet version
| DotNet ("5.0" as version)
| DotNet version -> Some $"v{version}"
| _ -> None) |> Option.defaultValue owner.NetFrameworkVersion
| _ -> None) |> Option.defaultValue owner.NetFrameworkVersion
LinuxFxVersion = match owner.LinuxFxVersion with
| None -> None
| Some target ->
this.Runtime |> Option.map (fun r -> r |> function
| DotNetCore version -> Some $"DOTNETCORE|{version}"
| DotNet version -> Some $"DOTNETCORE|{version}"
| Node version -> Some $"NODE|{version}"
| Php version -> Some $"PHP|{version}"
| Ruby version -> Some $"RUBY|{version}"
| Java (runtime, JavaSE) -> Some $"JAVA|{runtime.Version}-{runtime.Jre}"
| Java (runtime, (Tomcat version)) -> Some $"TOMCAT|{version}-{runtime.Jre}"
| Java (Java8, WildFly14) -> Some $"WILDFLY|14-{Java8.Jre}"
| Python (linuxVersion, _) -> Some $"PYTHON|{linuxVersion}"
| _ -> None) |> Option.defaultValue owner.LinuxFxVersion
PostDeployActions =
[
fun rg ->
Expand Down
31 changes: 30 additions & 1 deletion src/Tests/WebApp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2075,7 +2075,7 @@ let tests =
Expect.equal slot.Name.Value "webapp/deployment" "Slot name was not as expected"
Expect.equal slot.AlwaysOn false "Slot was not set to Always On -> false"
}
test "WebApp supports runtime on slot" {
test "WebApp supports network framework runtime on slot" {
let slot =
appSlot {
name "warm-up"
Expand Down Expand Up @@ -2103,4 +2103,33 @@ let tests =

Expect.equal netFrameworkVersion "v8.0" "Net Framework version should be set to 8.0"
}
test "WebApp supports runtime on a linux slot" {
let slot =
appSlot {
name "warm-up"
runtime Runtime.DotNet80
}

let app =
webApp {
name "webapp"
operating_system Linux
add_slot slot
}

Expect.isTrue (app.CommonWebConfig.Slots.ContainsKey "warm-up") "Config should contain slot"

let slots =
app
|> getResources
|> getResource<Arm.Web.Site>
|> List.filter (fun x -> x.ResourceType = Arm.Web.slots)
// Default "production" slot is not included as it is created automatically in Azure
Expect.hasLength slots 1 "Should only be 1 slot"

let linuxFxVersion =
Expect.wantSome slots[0].LinuxFxVersion "Linux FX version should be set"

Expect.equal linuxFxVersion "DOTNETCORE|8.0" "Linux FX version should be set to 8.0"
}
]
Loading