Skip to content

Commit b25c0da

Browse files
committed
Adding F# to site warmup logic
1 parent 078f29d commit b25c0da

File tree

8 files changed

+35
-9
lines changed

8 files changed

+35
-9
lines changed
File renamed without changes.
File renamed without changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"bindings": [
3+
{
4+
"type": "manualTrigger",
5+
"name": "input",
6+
"direction": "in"
7+
}
8+
]
9+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
open System
2+
3+
let Run(input: string, log: TraceWriter) =
4+
log.Info(sprintf "Input=%s" input)
File renamed without changes.

src/WebJobs.Script.WebHost/WebJobs.Script.WebHost.csproj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@
307307
</ItemGroup>
308308
<ItemGroup>
309309
<Content Include="Global.asax" />
310+
<EmbeddedResource Include="Resources\Functions\Test-FSharp\run.fsx" />
310311
<Content Include="Web.config" />
311312
</ItemGroup>
312313
<ItemGroup>
@@ -357,9 +358,10 @@
357358
<None Include="App_Data\secrets\WebHook-Generic-CSharp.json" />
358359
<None Include="App_Data\secrets\WebHook-Generic.json" />
359360
<None Include="Properties\PublishProfiles\FileSystem.pubxml" />
360-
<EmbeddedResource Include="Resources\Test\function.json" />
361-
<EmbeddedResource Include="Resources\Test\host.json" />
362-
<EmbeddedResource Include="Resources\Test\run.csx" />
361+
<EmbeddedResource Include="Resources\Functions\host.json" />
362+
<EmbeddedResource Include="Resources\Functions\Test-CSharp\function.json" />
363+
<EmbeddedResource Include="Resources\Functions\Test-CSharp\run.csx" />
364+
<EmbeddedResource Include="Resources\Functions\Test-FSharp\function.json" />
363365
<None Include="Web.Debug.config">
364366
<DependentUpon>Web.config</DependentUpon>
365367
</None>

src/WebJobs.Script.WebHost/WebScriptHostManager.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,17 +163,25 @@ public static void WarmUp(WebHostSettings settings)
163163
}
164164
Directory.CreateDirectory(rootPath);
165165

166-
string content = ReadResourceString("Test.host.json");
166+
string content = ReadResourceString("Functions.host.json");
167167
File.WriteAllText(Path.Combine(rootPath, "host.json"), content);
168168

169-
string functionPath = Path.Combine(rootPath, "Test");
169+
// read in the C# function
170+
string functionPath = Path.Combine(rootPath, "Test-CSharp");
170171
Directory.CreateDirectory(functionPath);
171-
content = ReadResourceString("Test.function.json");
172+
content = ReadResourceString("Functions.Test_CSharp.function.json");
172173
File.WriteAllText(Path.Combine(functionPath, "function.json"), content);
173-
174-
content = ReadResourceString("Test.run.csx");
174+
content = ReadResourceString("Functions.Test_CSharp.run.csx");
175175
File.WriteAllText(Path.Combine(functionPath, "run.csx"), content);
176176

177+
// read in the F# function
178+
functionPath = Path.Combine(rootPath, "Test-FSharp");
179+
Directory.CreateDirectory(functionPath);
180+
content = ReadResourceString("Functions.Test_FSharp.function.json");
181+
File.WriteAllText(Path.Combine(functionPath, "function.json"), content);
182+
content = ReadResourceString("Functions.Test_FSharp.run.fsx");
183+
File.WriteAllText(Path.Combine(functionPath, "run.fsx"), content);
184+
177185
traceWriter.Info("Warm up functions deployed");
178186

179187
ScriptHostConfiguration config = new ScriptHostConfiguration
@@ -196,7 +204,8 @@ public static void WarmUp(WebHostSettings settings)
196204
{
197205
{ "input", "{}" }
198206
};
199-
host.CallAsync("Test", arguments).Wait();
207+
host.CallAsync("Test-CSharp", arguments).Wait();
208+
host.CallAsync("Test-FSharp", arguments).Wait();
200209
host.Stop();
201210

202211
traceWriter.Info("Warm up succeeded");

test/WebJobs.Script.Tests/StandbyModeTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ public void Warmup_Succeeds()
106106
var content = File.ReadAllText(hostLogFile);
107107

108108
Assert.Contains("Warm up started", content);
109+
Assert.Contains("Executed: 'Functions.Test-CSharp' (Succeeded)", content);
110+
Assert.Contains("Executed: 'Functions.Test-FSharp' (Succeeded)", content);
109111
Assert.Contains("Warm up succeeded", content);
110112
}
111113
}

0 commit comments

Comments
 (0)