diff --git a/.github/workflows/run-validation.yml b/.github/workflows/run-validation.yml index 13814ae3..d7a964aa 100644 --- a/.github/workflows/run-validation.yml +++ b/.github/workflows/run-validation.yml @@ -463,7 +463,7 @@ jobs: uses: ./ with: appSourcePath: '${{ github.workspace }}/oryx/tests/SampleApps/DotNetCore/NetCore6PreviewWebApp' - containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + containerAppName: ${{ env.TEST_EXISTING_CONTAINER_APP }} containerAppEnvironment: ${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }} resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NO_ACR_NAME }} disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} diff --git a/azurecontainerapps.ts b/azurecontainerapps.ts index f3989e36..d57c7cd7 100644 --- a/azurecontainerapps.ts +++ b/azurecontainerapps.ts @@ -540,12 +540,13 @@ export class azurecontainerapps { * Creates or updates the Container App. */ private static async createOrUpdateContainerApp() { + var createOrUpdateContainerAppWithUp = !this.util.isNullOrEmpty(this.appSourcePath) && this.useInternalRegistry if (!this.containerAppExists) { if (!this.util.isNullOrEmpty(this.yamlConfigPath)) { // Create the Container App from the YAML configuration file await this.appHelper.createContainerAppFromYaml(this.containerAppName, this.resourceGroup, this.yamlConfigPath); - } else if ((!this.util.isNullOrEmpty(this.appSourcePath) && this.useInternalRegistry)) { - await this.appHelper.createContainerAppWithUp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.commandLineArgs); + } else if (createOrUpdateContainerAppWithUp) { + await this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.location, this.commandLineArgs); } else { // Create the Container App from command line arguments await this.appHelper.createContainerApp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.commandLineArgs); @@ -561,7 +562,7 @@ export class azurecontainerapps { return; } - if (this.shouldUseUpdateCommand) { + if (this.shouldUseUpdateCommand && !createOrUpdateContainerAppWithUp) { // Update the Container Registry details on the existing Container App, if provided as an input if (!this.util.isNullOrEmpty(this.registryUrl) && !this.util.isNullOrEmpty(this.registryUsername) && !this.util.isNullOrEmpty(this.registryPassword)) { await this.appHelper.updateContainerAppRegistryDetails(this.containerAppName, this.resourceGroup, this.registryUrl, this.registryUsername, this.registryPassword); @@ -569,6 +570,8 @@ export class azurecontainerapps { // Update the Container App using the 'update' command await this.appHelper.updateContainerApp(this.containerAppName, this.resourceGroup, this.commandLineArgs); + } else if (createOrUpdateContainerAppWithUp) { + await this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.location, this.commandLineArgs); } else { // Update the Container App using the 'up' command await this.appHelper.updateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs, this.ingress, this.targetPort); diff --git a/dist/index.js b/dist/index.js index 1c360505..cbba55b2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -626,9 +626,11 @@ var azurecontainerapps = /** @class */ (function () { */ azurecontainerapps.createOrUpdateContainerApp = function () { return __awaiter(this, void 0, void 0, function () { + var createOrUpdateContainerAppWithUp; return __generator(this, function (_a) { switch (_a.label) { case 0: + createOrUpdateContainerAppWithUp = !this.util.isNullOrEmpty(this.appSourcePath) && this.useInternalRegistry; if (!!this.containerAppExists) return [3 /*break*/, 7]; if (!!this.util.isNullOrEmpty(this.yamlConfigPath)) return [3 /*break*/, 2]; // Create the Container App from the YAML configuration file @@ -638,8 +640,8 @@ var azurecontainerapps = /** @class */ (function () { _a.sent(); return [3 /*break*/, 6]; case 2: - if (!(!this.util.isNullOrEmpty(this.appSourcePath) && this.useInternalRegistry)) return [3 /*break*/, 4]; - return [4 /*yield*/, this.appHelper.createContainerAppWithUp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.commandLineArgs)]; + if (!createOrUpdateContainerAppWithUp) return [3 /*break*/, 4]; + return [4 /*yield*/, this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.location, this.commandLineArgs)]; case 3: _a.sent(); return [3 /*break*/, 6]; @@ -660,7 +662,7 @@ var azurecontainerapps = /** @class */ (function () { _a.sent(); return [2 /*return*/]; case 9: - if (!this.shouldUseUpdateCommand) return [3 /*break*/, 13]; + if (!(this.shouldUseUpdateCommand && !createOrUpdateContainerAppWithUp)) return [3 /*break*/, 13]; if (!(!this.util.isNullOrEmpty(this.registryUrl) && !this.util.isNullOrEmpty(this.registryUsername) && !this.util.isNullOrEmpty(this.registryPassword))) return [3 /*break*/, 11]; return [4 /*yield*/, this.appHelper.updateContainerAppRegistryDetails(this.containerAppName, this.resourceGroup, this.registryUrl, this.registryUsername, this.registryPassword)]; case 10: @@ -672,21 +674,27 @@ var azurecontainerapps = /** @class */ (function () { case 12: // Update the Container App using the 'update' command _a.sent(); - return [3 /*break*/, 15]; - case 13: + return [3 /*break*/, 17]; + case 13: + if (!createOrUpdateContainerAppWithUp) return [3 /*break*/, 15]; + return [4 /*yield*/, this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.location, this.commandLineArgs)]; + case 14: + _a.sent(); + return [3 /*break*/, 17]; + case 15: // Update the Container App using the 'up' command return [4 /*yield*/, this.appHelper.updateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs, this.ingress, this.targetPort)]; - case 14: + case 16: // Update the Container App using the 'up' command _a.sent(); - _a.label = 15; - case 15: - if (!(this.ingress == 'disabled')) return [3 /*break*/, 17]; + _a.label = 17; + case 17: + if (!(this.ingress == 'disabled')) return [3 /*break*/, 19]; return [4 /*yield*/, this.appHelper.disableContainerAppIngress(this.containerAppName, this.resourceGroup)]; - case 16: + case 18: _a.sent(); - _a.label = 17; - case 17: return [2 /*return*/]; + _a.label = 19; + case 19: return [2 /*return*/]; } }); }); @@ -4752,7 +4760,7 @@ var ContainerAppHelper = /** @class */ (function () { * @param environment - the Container App Environment that will be associated with the Container App * @param optionalCmdArgs - a set of optional command line arguments */ - ContainerAppHelper.prototype.createContainerAppWithUp = function (containerAppName, resourceGroup, environment, optionalCmdArgs) { + ContainerAppHelper.prototype.createOrUpdateContainerAppWithUp = function (containerAppName, resourceGroup, environment, location, optionalCmdArgs) { return __awaiter(this, void 0, void 0, function () { var command_2, err_2; return __generator(this, function (_a) { @@ -4762,7 +4770,7 @@ var ContainerAppHelper = /** @class */ (function () { _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command_2 = "az containerapp up -n " + containerAppName + " -g " + resourceGroup + " --environment " + environment + " --location northcentralusstage"; + command_2 = "az containerapp up -n " + containerAppName + " -g " + resourceGroup + " --environment " + environment + " -l " + location; optionalCmdArgs.forEach(function (val) { command_2 += " " + val; }); diff --git a/src/ContainerAppHelper.ts b/src/ContainerAppHelper.ts index ceca1724..b4cda8b7 100644 --- a/src/ContainerAppHelper.ts +++ b/src/ContainerAppHelper.ts @@ -50,14 +50,15 @@ export class ContainerAppHelper { * @param environment - the Container App Environment that will be associated with the Container App * @param optionalCmdArgs - a set of optional command line arguments */ - public async createContainerAppWithUp( + public async createOrUpdateContainerAppWithUp( containerAppName: string, resourceGroup: string, environment: string, + location: string, optionalCmdArgs: string[]) { toolHelper.writeDebug(`Attempting to create Container App with name "${containerAppName}" in resource group "${resourceGroup}"`); try { - let command = `az containerapp up -n ${containerAppName} -g ${resourceGroup} --environment ${environment} --location northcentralusstage`; + let command = `az containerapp up -n ${containerAppName} -g ${resourceGroup} --environment ${environment} -l ${location}`; optionalCmdArgs.forEach(function (val: string) { command += ` ${val}`; });