From 13fdc5a3ff8fd6a3ee27863cb83c321dea294939 Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Mon, 15 Jun 2020 13:45:29 -0300 Subject: [PATCH] fix(azuredeployer.gbapp): Fix in wheather bot exists on Azure. --- .../services/AzureDeployerService.ts | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/azuredeployer.gbapp/services/AzureDeployerService.ts b/packages/azuredeployer.gbapp/services/AzureDeployerService.ts index dab34502..b278803c 100644 --- a/packages/azuredeployer.gbapp/services/AzureDeployerService.ts +++ b/packages/azuredeployer.gbapp/services/AzureDeployerService.ts @@ -229,18 +229,20 @@ export class AzureDeployerService implements IGBInstallationDeployer { const accessToken = await GBAdminService.getADALTokenFromUsername(username, password); const httpClient = new ServiceClient(); - const query = `subscriptions/${subscriptionId}/resourceGroups/${group}/providers/${ + const query = `providers/${ this.provider - }/botServices/${botId}?api-version=${this.apiVersion}`; + }/checkNameAvailability/Action?api-version=${this.apiVersion}`; + const url = urlJoin(baseUrl, query); - const req = AzureDeployerService.createRequestObject(url, accessToken, 'GET', undefined); + const body = { + name: botId, + type: "botServices" + }; + + const req = AzureDeployerService.createRequestObject(url, accessToken, 'POST', JSON.stringify(body)); const res = await httpClient.sendRequest(req); - // CHECK - if (!JSON.parse(res.bodyAsText).id) { - return false; - } else { - return true; - } + + return res.parsedBody.valid; } public async updateBotProxy(botId, group, endpoint) {