fix(azuredeployer.gbapp): Fix in wheather bot exists on Azure.

This commit is contained in:
Rodrigo Rodriguez 2020-06-15 13:45:29 -03:00
parent 8c68332802
commit 13fdc5a3ff

View file

@ -229,18 +229,20 @@ export class AzureDeployerService implements IGBInstallationDeployer {
const accessToken = await GBAdminService.getADALTokenFromUsername(username, password); const accessToken = await GBAdminService.getADALTokenFromUsername(username, password);
const httpClient = new ServiceClient(); const httpClient = new ServiceClient();
const query = `subscriptions/${subscriptionId}/resourceGroups/${group}/providers/${ const query = `providers/${
this.provider this.provider
}/botServices/${botId}?api-version=${this.apiVersion}`; }/checkNameAvailability/Action?api-version=${this.apiVersion}`;
const url = urlJoin(baseUrl, query); 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); const res = await httpClient.sendRequest(req);
// CHECK
if (!JSON.parse(res.bodyAsText).id) { return res.parsedBody.valid;
return false;
} else {
return true;
}
} }
public async updateBotProxy(botId, group, endpoint) { public async updateBotProxy(botId, group, endpoint) {