Skip to content

Commit 7c7c96d

Browse files
committed
Adding HostId to HostStatus endpoint
1 parent 9b4ab55 commit 7c7c96d

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/WebJobs.Script.WebHost/Controllers/AdminController.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ public FunctionStatus GetFunctionStatus(string name)
8585
[Route("admin/host/status")]
8686
public HostStatus GetHostStatus()
8787
{
88-
HostStatus status = new HostStatus();
88+
HostStatus status = new HostStatus
89+
{
90+
Id = _scriptHostManager.Instance?.ScriptConfig.HostConfig.HostId
91+
};
8992

9093
var lastError = _scriptHostManager.LastError;
9194
if (lastError != null)

src/WebJobs.Script.WebHost/Models/HostStatus.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ public HostStatus()
1414
}
1515

1616
/// <summary>
17-
/// Gets the host version.
17+
/// Gets or sets the host id.
18+
/// </summary>
19+
[JsonProperty(PropertyName = "id", DefaultValueHandling = DefaultValueHandling.Ignore)]
20+
public string Id { get; set; }
21+
22+
/// <summary>
23+
/// Gets or sets the host version.
1824
/// </summary>
1925
[JsonProperty(PropertyName = "version", DefaultValueHandling = DefaultValueHandling.Ignore)]
2026
public string Version { get; set; }

test/WebJobs.Script.Tests/SamplesEndToEndTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,8 @@ public async Task HostStatus_Succeeds()
814814

815815
AssemblyFileVersionAttribute fileVersionAttr = typeof(HostStatus).Assembly.GetCustomAttribute<AssemblyFileVersionAttribute>();
816816
string expectedVersion = fileVersionAttr.Version;
817+
string expectedId = "5a709861cab44e68bfed5d2c2fe7fc0c";
818+
Assert.Equal(expectedId, jsonContent["id"].ToString());
817819
Assert.Equal(expectedVersion, jsonContent["version"].ToString());
818820

819821
// Now ensure XML content works
@@ -828,6 +830,8 @@ public async Task HostStatus_Succeeds()
828830
XDocument doc = XDocument.Parse(content);
829831
var node = doc.Descendants(XName.Get("Version", ns)).Single();
830832
Assert.Equal(expectedVersion, node.Value);
833+
node = doc.Descendants(XName.Get("Id", ns)).Single();
834+
Assert.Equal(expectedId, node.Value);
831835

832836
node = doc.Descendants(XName.Get("Errors", ns)).Single();
833837
Assert.True(node.IsEmpty);

0 commit comments

Comments
 (0)