Skip to content

Commit

Permalink
Merge pull request #1077 from Microsoft/tomlm/cherryPickGovEndpoint
Browse files Browse the repository at this point in the history
Cherry-pick pull request #1076 from 4.1 for US Gov Data centers
  • Loading branch information
Tom Laird-McConnell authored Oct 31, 2018
2 parents 3d3de0d + 0f187ea commit 265c190
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
15 changes: 15 additions & 0 deletions libraries/Microsoft.Bot.Configuration/Services/LuisService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ public LuisService()
/// <returns>endpoint url</returns>
public string GetEndpoint()
{
var region = this.Region.ToLower();

// usgovvirginia is that actual azure region name, but the cognitive service team called their endpoint 'virginia' instead of 'usgovvirginia'
// We handle both region names as an alias for virginia.api.cognitive.microsoft.us
if (region == "virginia" || region == "usgovvirginia")
{
return $"https://virginia.api.cognitive.microsoft.us";
}

// if it starts with usgov or usdod then it is a .us TLD
else if (region.StartsWith("usgov") || region.StartsWith("usdod"))
{
return $"https://{this.Region}.api.cognitive.microsoft.us";
}

return $"https://{this.Region}.api.cognitive.microsoft.com";
}

Expand Down
9 changes: 9 additions & 0 deletions tests/Microsoft.Bot.Configuration.Tests/ServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ public void LuisReturnsCorrectUrl()
{
var luis = new LuisService() { Region = "westus" };
Assert.AreEqual(luis.GetEndpoint(), "https://westus.api.cognitive.microsoft.com");

luis = new LuisService() { Region = "virginia" };
Assert.AreEqual(luis.GetEndpoint(), "https://virginia.api.cognitive.microsoft.us");

luis = new LuisService() { Region = "usgovvirginia" };
Assert.AreEqual(luis.GetEndpoint(), "https://virginia.api.cognitive.microsoft.us");

luis = new LuisService() { Region = "usgoviowa" };
Assert.AreEqual(luis.GetEndpoint(), "https://usgoviowa.api.cognitive.microsoft.us");
}


Expand Down

0 comments on commit 265c190

Please sign in to comment.