Skip to content

Commit

Permalink
Merge 4d23cc6 into c4d835a
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Laird-McConnell committed Oct 31, 2018
2 parents c4d835a + 4d23cc6 commit b87b645
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
16 changes: 15 additions & 1 deletion libraries/botframework-config/src/models/luisService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,21 @@ export class LuisService extends ConnectedService implements ILuisService {

// get endpoint for the luis service
public getEndpoint(): string {
return `https://${this.region}.api.cognitive.microsoft.com`;
let reg = this.region.toLowerCase();

// 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 (reg === "virginia" || reg === "usgovvirginia")
{
return `https://virginia.api.cognitive.microsoft.us`;
}
// regardless, if it starts with usgov or usdod then it is us TLD (ex: api.cognitive.microsoft.us )
else if (reg.startsWith("usgov") || reg.startsWith("usdod"))
{
return `https://${this.region}.api.cognitive.microsoft.us`;
}

return `https://${this.region}.api.cognitive.microsoft.com`;
}

// encrypt keys in service
Expand Down
9 changes: 9 additions & 0 deletions libraries/botframework-config/tests/service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ describe("Service Tests", () => {
it("Luis.getEndpoint() returns correct url for region", async () => {
let luis = new bf.LuisService({ region: "westus" });
assert.equal(luis.getEndpoint(), `https://westus.api.cognitive.microsoft.com`);

luis = new bf.LuisService({ region: "virginia" });
assert.equal(luis.getEndpoint(), `https://virginia.api.cognitive.microsoft.us`);

luis = new bf.LuisService({ region: "usgovvirginia" });
assert.equal(luis.getEndpoint(), `https://virginia.api.cognitive.microsoft.us`);

luis = new bf.LuisService({ region: "usgoviowa" });
assert.equal(luis.getEndpoint(), `https://usgoviowa.api.cognitive.microsoft.us`);
});

it("QNAMaker corretly adds suffix", () => {
Expand Down

0 comments on commit b87b645

Please sign in to comment.