diff --git a/Kudu.Contracts/Deployment/DeployResult.cs b/Kudu.Contracts/Deployment/DeployResult.cs index 873f7a49d..6cba69b53 100644 --- a/Kudu.Contracts/Deployment/DeployResult.cs +++ b/Kudu.Contracts/Deployment/DeployResult.cs @@ -61,5 +61,8 @@ public class DeployResult [DataMember(Name = "log_url")] public Uri LogUrl { get; set; } + + [DataMember(Name = "site_name")] + public string SiteName { get; set; } } -} +} \ No newline at end of file diff --git a/Kudu.Contracts/Deployment/IDeploymentStatusFile.cs b/Kudu.Contracts/Deployment/IDeploymentStatusFile.cs index 5f18dc99c..a76496acc 100644 --- a/Kudu.Contracts/Deployment/IDeploymentStatusFile.cs +++ b/Kudu.Contracts/Deployment/IDeploymentStatusFile.cs @@ -19,7 +19,8 @@ public interface IDeploymentStatusFile bool Complete { get; set; } bool IsTemporary { get; set; } bool IsReadOnly { get; set; } + string SiteName { get; } void Save(); } -} +} \ No newline at end of file diff --git a/Kudu.Core.Test/Deployment/DeploymentManagerFacts.cs b/Kudu.Core.Test/Deployment/DeploymentManagerFacts.cs index ceeae3221..b285705d4 100644 --- a/Kudu.Core.Test/Deployment/DeploymentManagerFacts.cs +++ b/Kudu.Core.Test/Deployment/DeploymentManagerFacts.cs @@ -90,6 +90,8 @@ public class TestDeploymentStatusFile : IDeploymentStatusFile public bool IsReadOnly { get; set; } + public string SiteName { get; set; } + public void Save() { // Do nothing. diff --git a/Kudu.Core/Deployment/DeploymentManager.cs b/Kudu.Core/Deployment/DeploymentManager.cs index 591171193..c38793284 100644 --- a/Kudu.Core/Deployment/DeploymentManager.cs +++ b/Kudu.Core/Deployment/DeploymentManager.cs @@ -500,7 +500,8 @@ private DeployResult GetResult(string id, string activeDeploymentId, bool isDepl IsReadOnly = file.IsReadOnly, Current = file.Id == activeDeploymentId, ReceivedTime = file.ReceivedTime, - LastSuccessEndTime = file.LastSuccessEndTime + LastSuccessEndTime = file.LastSuccessEndTime, + SiteName = file.SiteName }; } diff --git a/Kudu.Core/Deployment/DeploymentStatusFile.cs b/Kudu.Core/Deployment/DeploymentStatusFile.cs index ae61f0228..e2ec826e6 100644 --- a/Kudu.Core/Deployment/DeploymentStatusFile.cs +++ b/Kudu.Core/Deployment/DeploymentStatusFile.cs @@ -3,7 +3,6 @@ using System.IO.Abstractions; using System.Xml.Linq; using Kudu.Contracts.Infrastructure; -using Kudu.Core.Deployment; using Kudu.Core.Infrastructure; namespace Kudu.Core.Deployment @@ -29,6 +28,8 @@ private DeploymentStatusFile(string id, IEnvironment environment, IFileSystem fi Id = id; + SiteName = GetSiteName(environment); + if (document != null) { Initialize(document); @@ -136,6 +137,7 @@ private void Initialize(XDocument document) public bool Complete { get; set; } public bool IsTemporary { get; set; } public bool IsReadOnly { get; set; } + public string SiteName { get; private set; } public void Save() { @@ -194,10 +196,24 @@ private static string GetOptionalElementValue(XElement element, string localName } return child != null ? child.Value : null; } - + private static DateTime? ParseDateTime(string value) { return !String.IsNullOrEmpty(value) ? DateTime.Parse(value).ToUniversalTime() : (DateTime?)null; } + + private static string GetSiteName(IEnvironment environment) + { + // Try to get the site name from the environment (WAWS will set it) + string siteName = System.Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME"); + + if (String.IsNullOrEmpty(siteName)) + { + // Otherwise get it from the root directory name + siteName = Path.GetFileName(environment.RootPath); + } + + return siteName; + } } -} +} \ No newline at end of file