Skip to content

Commit

Permalink
Fix command to get location
Browse files Browse the repository at this point in the history
  • Loading branch information
snehapar9 committed Nov 11, 2023
1 parent a0cf129 commit 72b2602
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
3 changes: 1 addition & 2 deletions azurecontainerapps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
17 changes: 8 additions & 9 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions src/ContainerAppHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 72b2602

Please sign in to comment.