Skip to content

Commit

Permalink
Modify location
Browse files Browse the repository at this point in the history
  • Loading branch information
snehapar9 committed Nov 11, 2023
1 parent 4bae842 commit 5b3fb36
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
14 changes: 7 additions & 7 deletions azurecontainerapps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,14 @@ export class azurecontainerapps {

let doesContainerAppExist = await this.appHelper.doesContainerAppExist(this.containerAppName, this.resourceGroup);
if (doesContainerAppExist) {
var environmentId = await this.appHelper.getExistingContainerAppEnvironmentId(this.containerAppName);
var environmentId = await this.appHelper.getExistingContainerAppEnvironmentId(this.containerAppName, this.resourceGroup);
var environmentName = environmentId.split("/").pop();
location = await this.appHelper.getExistingContainerAppEnvironmentLocation(environmentName);
location = await this.appHelper.getExistingContainerAppEnvironmentLocation(environmentName, this.resourceGroup);
}
// If no location was provided, use the default location for the Container App service
if (this.util.isNullOrEmpty(location)) {
location = await this.appHelper.getDefaultContainerAppLocation();
}
if (this.util.isNullOrEmpty(location)) {
location = await this.appHelper.getDefaultContainerAppLocation();
}

return location;
}
Expand Down Expand Up @@ -311,7 +311,7 @@ export class azurecontainerapps {
}

// Set default location to the location of the Container App environment
this.location = await this.appHelper.getExistingContainerAppEnvironmentLocation(containerAppEnvironment);
this.location = await this.appHelper.getExistingContainerAppEnvironmentLocation(containerAppEnvironment, this.resourceGroup);

return containerAppEnvironment;
}
Expand Down Expand Up @@ -581,7 +581,7 @@ export class azurecontainerapps {
// Update the Container App using the 'update' command
await this.appHelper.updateContainerApp(this.containerAppName, this.resourceGroup, this.commandLineArgs);
} else if (this.shouldCreateOrUpdateContainerAppWithUp) {
await this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs);
await this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs, this.location);
} else {
// Update the Container App using the 'up' command
await this.appHelper.updateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs, this.ingress, this.targetPort);
Expand Down
16 changes: 8 additions & 8 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,11 @@ var azurecontainerapps = /** @class */ (function () {
case 1:
doesContainerAppExist = _a.sent();
if (!doesContainerAppExist) return [3 /*break*/, 4];
return [4 /*yield*/, this.appHelper.getExistingContainerAppEnvironmentId(this.containerAppName)];
return [4 /*yield*/, this.appHelper.getExistingContainerAppEnvironmentId(this.containerAppName, this.resourceGroup)];
case 2:
environmentId = _a.sent();
environmentName = environmentId.split("/").pop();
return [4 /*yield*/, this.appHelper.getExistingContainerAppEnvironmentLocation(environmentName)];
return [4 /*yield*/, this.appHelper.getExistingContainerAppEnvironmentLocation(environmentName, this.resourceGroup)];
case 3:
location = _a.sent();
_a.label = 4;
Expand Down Expand Up @@ -358,7 +358,7 @@ var azurecontainerapps = /** @class */ (function () {
case 5:
// Set default location to the location of the Container App environment
_a = this;
return [4 /*yield*/, this.appHelper.getExistingContainerAppEnvironmentLocation(containerAppEnvironment)];
return [4 /*yield*/, this.appHelper.getExistingContainerAppEnvironmentLocation(containerAppEnvironment, this.resourceGroup)];
case 6:
// Set default location to the location of the Container App environment
_a.location = _b.sent();
Expand Down Expand Up @@ -681,7 +681,7 @@ var azurecontainerapps = /** @class */ (function () {
return [3 /*break*/, 17];
case 13:
if (!this.shouldCreateOrUpdateContainerAppWithUp) return [3 /*break*/, 15];
return [4 /*yield*/, this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs)];
return [4 /*yield*/, this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs, this.location)];
case 14:
_a.sent();
return [3 /*break*/, 17];
Expand Down Expand Up @@ -5104,14 +5104,14 @@ var ContainerAppHelper = /** @class */ (function () {
/**
* Gets the location of an existing Container App Environment
*/
ContainerAppHelper.prototype.getExistingContainerAppEnvironmentLocation = function (environmentName) {
ContainerAppHelper.prototype.getExistingContainerAppEnvironmentLocation = function (environmentName, resourceGroup) {
return __awaiter(this, void 0, void 0, function () {
var command, executionResult, err_13;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
command = "az containerapp env show -n " + environmentName + " --query \"[0].location\"";
command = "az containerapp env show -n " + environmentName + " -g " + resourceGroup + " --query \"[0].location\"";
return [4 /*yield*/, util.execute(command)];
case 1:
executionResult = _a.sent();
Expand All @@ -5128,14 +5128,14 @@ var ContainerAppHelper = /** @class */ (function () {
/**
* Gets the environment Id of an existing Container App
*/
ContainerAppHelper.prototype.getExistingContainerAppEnvironmentId = function (containerAppName) {
ContainerAppHelper.prototype.getExistingContainerAppEnvironmentId = 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 show -n " + containerAppName + " --query \"[0].properties.environmentId\"";
command = "az containerapp show -n " + containerAppName + " -g " + resourceGroup + " --query \"[0].properties.environmentId\"";
return [4 /*yield*/, util.execute(command)];
case 1:
executionResult = _a.sent();
Expand Down
8 changes: 4 additions & 4 deletions src/ContainerAppHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ export class ContainerAppHelper {
/**
* Gets the location of an existing Container App Environment
*/
public async getExistingContainerAppEnvironmentLocation(environmentName: string) {
public async getExistingContainerAppEnvironmentLocation(environmentName: string, resourceGroup: string) {
try {
let command = `az containerapp env show -n ${environmentName} --query "[0].location"`
let command = `az containerapp env show -n ${environmentName} -g ${resourceGroup} --query "[0].location"`
let executionResult = await util.execute(command);
return executionResult.exitCode === 0 ? executionResult.stdout : null;
} catch (err) {
Expand All @@ -288,9 +288,9 @@ export class ContainerAppHelper {
/**
* Gets the environment Id of an existing Container App
*/
public async getExistingContainerAppEnvironmentId(containerAppName: string) {
public async getExistingContainerAppEnvironmentId(containerAppName: string, resourceGroup: string) {
try {
let command = `az containerapp show -n ${containerAppName} --query "[0].properties.environmentId"`
let command = `az containerapp show -n ${containerAppName} -g ${resourceGroup} --query "[0].properties.environmentId"`
let executionResult = await util.execute(command);
return executionResult.exitCode === 0 ? executionResult.stdout : null;
} catch (err) {
Expand Down

0 comments on commit 5b3fb36

Please sign in to comment.