diff --git a/azurecontainerapps.ts b/azurecontainerapps.ts index 0b1d93f7..a6b557d7 100644 --- a/azurecontainerapps.ts +++ b/azurecontainerapps.ts @@ -236,8 +236,7 @@ export class azurecontainerapps { if (!this.util.isNullOrEmpty(resourceGroup)) { let doesContainerAppExist = await this.appHelper.doesContainerAppExist(this.containerAppName, resourceGroup); if (doesContainerAppExist) { - var environmentId = await this.appHelper.getExistingContainerAppEnvironmentId(this.containerAppName, resourceGroup); - var environmentName = environmentId.split("/").pop(); + var environmentName = await this.appHelper.getExistingContainerAppEnvironmentName(this.containerAppName, resourceGroup); location = await this.appHelper.getExistingContainerAppEnvironmentLocation(environmentName, resourceGroup); } } diff --git a/dist/index.js b/dist/index.js index d9f270ca..e8a09f82 100644 --- a/dist/index.js +++ b/dist/index.js @@ -256,7 +256,7 @@ var azurecontainerapps = /** @class */ (function () { */ azurecontainerapps.getLocation = function () { return __awaiter(this, void 0, void 0, function () { - var location, resourceGroup, doesContainerAppExist, environmentId, environmentName; + var location, resourceGroup, doesContainerAppExist, environmentName; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -267,10 +267,9 @@ var azurecontainerapps = /** @class */ (function () { case 1: doesContainerAppExist = _a.sent(); if (!doesContainerAppExist) return [3 /*break*/, 4]; - return [4 /*yield*/, this.appHelper.getExistingContainerAppEnvironmentId(this.containerAppName, resourceGroup)]; + return [4 /*yield*/, this.appHelper.getExistingContainerAppEnvironmentName(this.containerAppName, resourceGroup)]; case 2: - environmentId = _a.sent(); - environmentName = environmentId.split("/").pop(); + environmentName = _a.sent(); return [4 /*yield*/, this.appHelper.getExistingContainerAppEnvironmentLocation(environmentName, resourceGroup)]; case 3: location = _a.sent(); @@ -5113,11 +5112,11 @@ var ContainerAppHelper = /** @class */ (function () { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); - command = "az containerapp env show -n " + environmentName + " -g " + resourceGroup + " --query \"[0].location\""; + command = "az containerapp env show -n " + environmentName + " -g " + resourceGroup + " --query location"; return [4 /*yield*/, util.execute(command)]; case 1: executionResult = _a.sent(); - return [2 /*return*/, executionResult.exitCode === 0 ? executionResult.stdout : null]; + return [2 /*return*/, executionResult.exitCode === 0 ? executionResult.stdout.toLowerCase().replace(/["() ]/g, "").trim() : null]; case 2: err_13 = _a.sent(); toolHelper.writeInfo(err_13.message); @@ -5130,18 +5129,18 @@ var ContainerAppHelper = /** @class */ (function () { /** * Gets the environment Id of an existing Container App */ - ContainerAppHelper.prototype.getExistingContainerAppEnvironmentId = function (containerAppName, resourceGroup) { + ContainerAppHelper.prototype.getExistingContainerAppEnvironmentName = function (containerAppName, resourceGroup) { return __awaiter(this, void 0, void 0, function () { var command, executionResult, err_14; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); - command = "az containerapp env show -n " + containerAppName + " -g " + resourceGroup + " --query \"[0].properties.environmentId\""; + command = "az containerapp show -n " + containerAppName + " -g " + resourceGroup + " --query properties.environmentId"; return [4 /*yield*/, util.execute(command)]; case 1: executionResult = _a.sent(); - return [2 /*return*/, executionResult.exitCode === 0 ? executionResult.stdout : null]; + return [2 /*return*/, executionResult.exitCode === 0 ? executionResult.stdout.split("/").pop() : null]; case 2: err_14 = _a.sent(); toolHelper.writeInfo(err_14.message); diff --git a/src/ContainerAppHelper.ts b/src/ContainerAppHelper.ts index 5df83303..b19dad7e 100644 --- a/src/ContainerAppHelper.ts +++ b/src/ContainerAppHelper.ts @@ -276,9 +276,9 @@ export class ContainerAppHelper { */ public async getExistingContainerAppEnvironmentLocation(environmentName: string, resourceGroup: string) { try { - let command = `az containerapp env show -n ${environmentName} -g ${resourceGroup} --query "[0].location"` + let command = `az containerapp env show -n ${environmentName} -g ${resourceGroup} --query location` let executionResult = await util.execute(command); - return executionResult.exitCode === 0 ? executionResult.stdout : null; + return executionResult.exitCode === 0 ? executionResult.stdout.toLowerCase().replace(/["() ]/g, "").trim() : null; } catch (err) { toolHelper.writeInfo(err.message); return null; @@ -288,11 +288,11 @@ export class ContainerAppHelper { /** * Gets the environment Id of an existing Container App */ - public async getExistingContainerAppEnvironmentId(containerAppName: string, resourceGroup: string) { + public async getExistingContainerAppEnvironmentName(containerAppName: string, resourceGroup: string) { try { - let command = `az containerapp env show -n ${containerAppName} -g ${resourceGroup} --query "[0].properties.environmentId"` + let command = `az containerapp show -n ${containerAppName} -g ${resourceGroup} --query properties.environmentId` let executionResult = await util.execute(command); - return executionResult.exitCode === 0 ? executionResult.stdout : null; + return executionResult.exitCode === 0 ? executionResult.stdout.split("/").pop() : null; } catch (err) { toolHelper.writeInfo(err.message); return null;