From f41e2a363cc9b777b6d04e98693186ae73b6ba31 Mon Sep 17 00:00:00 2001 From: Dan Vouaux Date: Wed, 8 Nov 2023 16:50:49 -0800 Subject: [PATCH 01/12] Update targeted builders to 20231107.2 --- README.md | 2 +- action.yml | 2 +- dist/index.js | 4 ++-- src/ContainerAppHelper.ts | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8f721a95..162a2b5a 100644 --- a/README.md +++ b/README.md @@ -170,7 +170,7 @@ For more information on the structure of the YAML configuration file, please vis | `resourceGroup` | No | The existing resource group that the Azure Container App will be created in. If not provided, this value will be `-rg` and its existence will first be checked before attempting to create it. | | `containerAppEnvironment` | No | The name of the Container App environment to use with the application. If not provided, an existing environment in the resource group of the Container App will be used, otherwise, an environment will be created in the formation `-env`. | | `runtimeStack` | No | The platform version stack used in the final runnable application image that is deployed to the Container App. The value should be provided in the formation `:`. If not provided, this value is determined by Oryx based on the contents of the provided application. Please refer to [this document](https://github.com/microsoft/Oryx/blob/main/doc/supportedRuntimeVersions.md) for more information on supported runtime stacks for Oryx. | -| `builderStack` | No | The stack (OS) that should be used to build the provided application source and produce the runnable application image. You can provide a specific image tag for the stack, such as "debian-bookworm-20231004.1", or you can provide a supported stack name, such as "debian-bookworm" or "debian-bullseye", and the latest supported image tag for that stack will be used. If no stack is provided, this action will attempt to build the provided application source with each supported stack until there's a successful build. | +| `builderStack` | No | The stack (OS) that should be used to build the provided application source and produce the runnable application image. You can provide a specific image tag for the stack, such as "debian-bookworm-20231107.2", or you can provide a supported stack name, such as "debian-bookworm" or "debian-bullseye", and the latest supported image tag for that stack will be used. If no stack is provided, this action will attempt to build the provided application source with each supported stack until there's a successful build. | | `targetPort` | No | The designated port for the application to run on. If no value is provided and the builder is used to build the runnable application image, the target port will be set to 80 for Python applications and 8080 for all other platform applications. If no value is provided when creating a Container App, the target port will default to 80. Note: when using this action to update a Container App, the target port may be updated if not provided based on changes to the ingress property. | | `location` | No | The location that the Container App (and other created resources) will be deployed to. To view locations suitable for creating the Container App in, please run the following: `az provider show -n Microsoft.App --query "resourceTypes[?resourceType=='containerApps'].locations"` | | `environmentVariables` | No | A list of environment variable(s) for the container. Space-separated values in 'key=value' format. Empty string to clear existing values. Prefix value with 'secretref:' to reference a secret. | diff --git a/action.yml b/action.yml index 384bff60..743c5c03 100644 --- a/action.yml +++ b/action.yml @@ -83,7 +83,7 @@ inputs: builderStack: description: | 'The stack (OS) that should be used to build the provided application source and produce the runnable application - image. You can provide a specific image tag for the stack, such as "debian-bullseye-20231004.1", or you can + image. You can provide a specific image tag for the stack, such as "debian-bullseye-20231107.2", or you can provide a supported stack name, such as "debian-bookworm" or "debian-bullseye", and the latest supported image tag for that stack will be used. If no stack is provided, this action will attempt to build the provided application source with each supported stack until there's a successful build.' diff --git a/dist/index.js b/dist/index.js index aac835a4..4bb882ba 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4710,8 +4710,8 @@ var Utility_1 = __nccwpck_require__(2135); var GitHubActionsToolHelper_1 = __nccwpck_require__(3185); var fs = __nccwpck_require__(7147); var ORYX_CLI_IMAGE = 'mcr.microsoft.com/oryx/cli:builder-debian-bullseye-20230926.1'; -var ORYX_BULLSEYE_BUILDER_IMAGE = 'mcr.microsoft.com/oryx/builder:debian-bullseye-20231025.1'; -var ORYX_BOOKWORM_BUILDER_IMAGE = 'mcr.microsoft.com/oryx/builder:debian-bookworm-20231025.1'; +var ORYX_BULLSEYE_BUILDER_IMAGE = 'mcr.microsoft.com/oryx/builder:debian-bullseye-20231107.2'; +var ORYX_BOOKWORM_BUILDER_IMAGE = 'mcr.microsoft.com/oryx/builder:debian-bookworm-20231107.2'; var ORYX_BUILDER_IMAGES = [ORYX_BULLSEYE_BUILDER_IMAGE, ORYX_BOOKWORM_BUILDER_IMAGE]; var IS_WINDOWS_AGENT = os.platform() == 'win32'; var PACK_CMD = IS_WINDOWS_AGENT ? path.join(os.tmpdir(), 'pack') : 'pack'; diff --git a/src/ContainerAppHelper.ts b/src/ContainerAppHelper.ts index 9a2a51c3..3c691d57 100644 --- a/src/ContainerAppHelper.ts +++ b/src/ContainerAppHelper.ts @@ -5,8 +5,8 @@ import { GitHubActionsToolHelper } from './GitHubActionsToolHelper' import fs = require('fs'); const ORYX_CLI_IMAGE: string = 'mcr.microsoft.com/oryx/cli:builder-debian-bullseye-20230926.1'; -const ORYX_BULLSEYE_BUILDER_IMAGE: string = 'mcr.microsoft.com/oryx/builder:debian-bullseye-20231025.1' -const ORYX_BOOKWORM_BUILDER_IMAGE: string = 'mcr.microsoft.com/oryx/builder:debian-bookworm-20231025.1' +const ORYX_BULLSEYE_BUILDER_IMAGE: string = 'mcr.microsoft.com/oryx/builder:debian-bullseye-20231107.2' +const ORYX_BOOKWORM_BUILDER_IMAGE: string = 'mcr.microsoft.com/oryx/builder:debian-bookworm-20231107.2' const ORYX_BUILDER_IMAGES: string[] = [ ORYX_BULLSEYE_BUILDER_IMAGE, ORYX_BOOKWORM_BUILDER_IMAGE ]; const IS_WINDOWS_AGENT: boolean = os.platform() == 'win32'; const PACK_CMD: string = IS_WINDOWS_AGENT ? path.join(os.tmpdir(), 'pack') : 'pack'; From be9f91dbb2ada9712b7dd4fc2306aa05f12e39e3 Mon Sep 17 00:00:00 2001 From: snehapar9 <108305436+snehapar9@users.noreply.github.com> Date: Thu, 9 Nov 2023 12:23:08 -0800 Subject: [PATCH 02/12] Build and push non cloud scenarios from GHA (#75) * Snap to containerapp version 0.3.43 * Modify update command * Comment out imageToDeploy * Add --debug to the update command * Comment out `--source` * Enable build and push from ghs * Build and push from gha * Ensuer -i and --source are not used together * Fix typo * Revert comment * Add global var to determine cloud build scenario --- .github/workflows/run-validation-oidc.yml | 679 ++++++++++++++++++++++ .github/workflows/run-validation.yml | 92 +++ azurecontainerapps.ts | 74 +-- dist/index.js | 298 +++++----- src/Utility.ts | 4 +- 5 files changed, 949 insertions(+), 198 deletions(-) create mode 100644 .github/workflows/run-validation-oidc.yml diff --git a/.github/workflows/run-validation-oidc.yml b/.github/workflows/run-validation-oidc.yml new file mode 100644 index 00000000..b26f30fc --- /dev/null +++ b/.github/workflows/run-validation-oidc.yml @@ -0,0 +1,679 @@ +name: Run validation on action + +on: + push: + branches: + - main + paths-ignore: + - '**.md' + pull_request: + branches: + - main + paths-ignore: + - '**.md' + +env: + TEST_FULL_ACR_NAME: ${{ vars.TEST_ACR_NAME }}.azurecr.io + TEST_IMAGE_REPOSITORY: github-actions/container-app + +jobs: + create-using-builder: + + name: 'Create app using builder' + runs-on: ubuntu-latest + permissions: + id-token: write #This is required for requesting the OIDC JWT Token + timeout-minutes: 10 + + env: + TEST_IMAGE_TAG: 'bs-${{ github.run_id }}' + TEST_CONTAINER_APP_NAME: 'gh-ca-bs-${{ github.run_id }}' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Clone Oryx repository + uses: actions/checkout@v3 + with: + repository: microsoft/Oryx + path: oryx + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + appSourcePath: '${{ github.workspace }}/oryx/tests/SampleApps/DotNetCore/NetCore6PreviewWebApp' + acrName: ${{ vars.TEST_ACR_NAME }} + acrUsername: ${{ secrets.TEST_REGISTRY_USERNAME }} + acrPassword: ${{ secrets.TEST_REGISTRY_PASSWORD }} + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + containerAppEnvironment: ${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + imageToBuild: ${{ env.TEST_FULL_ACR_NAME }}/${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Delete created Azure Container App + if: ${{ always() }} + shell: bash + run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + + - name: Delete pushed image + if: ${{ always() }} + shell: bash + run: az acr repository delete -n ${{ vars.TEST_ACR_NAME }} -t ${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} -y + + + create-using-builder-and-internal-registry: + + name: 'Create app using builder and push to internal registry' + runs-on: ubuntu-latest + permissions: + id-token: write #This is required for requesting the OIDC JWT Token + timeout-minutes: 10 + + env: + TEST_IMAGE_TAG: 'bs-${{ github.run_id }}' + TEST_CONTAINER_APP_NAME: 'gh-ca-bs-${{ github.run_id }}' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Clone Oryx repository + uses: actions/checkout@v3 + with: + repository: microsoft/Oryx + path: oryx + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + appSourcePath: '${{ github.workspace }}/oryx/tests/SampleApps/DotNetCore/NetCore6PreviewWebApp' + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NO_ACR_NAME }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Delete created Azure Container App + if: ${{ always() }} + shell: bash + run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + + + create-using-found-dockerfile: + + name: 'Create app using found Dockerfile' + runs-on: ubuntu-latest + permissions: + id-token: write #This is required for requesting the OIDC JWT Token + timeout-minutes: 10 + + env: + TEST_IMAGE_TAG: 'fd-${{ github.run_id }}' + TEST_CONTAINER_APP_NAME: 'gh-ca-fd-${{ github.run_id }}' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Clone Oryx repository + uses: actions/checkout@v3 + with: + repository: microsoft/Oryx + path: oryx + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + appSourcePath: '${{ github.workspace }}/oryx/tests/SampleApps/DotNetCore/Blazor_Function_Sample/blazor-sample-app' + acrName: ${{ vars.TEST_ACR_NAME }} + acrUsername: ${{ secrets.TEST_REGISTRY_USERNAME }} + acrPassword: ${{ secrets.TEST_REGISTRY_PASSWORD }} + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + containerAppEnvironment: ${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + imageToBuild: ${{ env.TEST_FULL_ACR_NAME }}/${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Delete created Azure Container App + if: ${{ always() }} + shell: bash + run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + + - name: Delete pushed image + if: ${{ always() }} + shell: bash + run: az acr repository delete -n ${{ vars.TEST_ACR_NAME }} -t ${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} -y + + create-using-provided-dockerfile: + + name: 'Create app using provided Dockerfile' + runs-on: ubuntu-latest + permissions: + id-token: write #This is required for requesting the OIDC JWT Token + timeout-minutes: 10 + + env: + TEST_IMAGE_TAG: 'pd-${{ github.run_id }}' + TEST_CONTAINER_APP_NAME: 'gh-ca-pd-${{ github.run_id }}' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Clone Oryx repository + uses: actions/checkout@v3 + with: + repository: microsoft/Oryx + path: oryx + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + appSourcePath: '${{ github.workspace }}/oryx/tests/SampleApps/DotNetCore/Blazor_Function_Sample/blazor-sample-app' + dockerfilePath: 'Dockerfile' + acrName: ${{ vars.TEST_ACR_NAME }} + acrUsername: ${{ secrets.TEST_REGISTRY_USERNAME }} + acrPassword: ${{ secrets.TEST_REGISTRY_PASSWORD }} + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + containerAppEnvironment: ${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + imageToBuild: ${{ env.TEST_FULL_ACR_NAME }}/${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Delete created Azure Container App + if: ${{ always() }} + shell: bash + run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + + - name: Delete pushed image + if: ${{ always() }} + shell: bash + run: az acr repository delete -n ${{ vars.TEST_ACR_NAME }} -t ${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} -y + + + create-using-image-linux: + + name: 'Create app using image on Linux runner' + runs-on: ubuntu-latest + permissions: + id-token: write #This is required for requesting the OIDC JWT Token + timeout-minutes: 10 + + env: + TEST_CONTAINER_APP_NAME: 'gh-ca-is-lin-${{ github.run_id }}' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + imageToDeploy: 'mcr.microsoft.com/azuredocs/containerapps-helloworld:latest' + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + containerAppEnvironment: ${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Delete created Azure Container App + if: ${{ always() }} + shell: bash + run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + + create-using-image-windows: + + name: 'Create app using image on Windows runner' + runs-on: windows-latest + permissions: + id-token: write #This is required for requesting the OIDC JWT Token + timeout-minutes: 10 + + env: + TEST_CONTAINER_APP_NAME: 'gh-ca-is-win-${{ github.run_id }}' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + imageToDeploy: 'mcr.microsoft.com/azuredocs/containerapps-helloworld:latest' + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + containerAppEnvironment: ${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Delete created Azure Container App + if: ${{ always() }} + shell: bash + run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + + create-using-image-new-env: + + name: 'Create app using image with new environment' + runs-on: ubuntu-latest + permissions: + id-token: write # This is required for requesting the OIDC JWT Token + timeout-minutes: 15 + + env: + TEST_CONTAINER_APP_NAME: 'gh-ca-is-ne-${{ github.run_id }}' + TEST_NEW_CONTAINER_APP_ENV: 'gh-ca-is-ne-${{ github.run_id }}-env' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + imageToDeploy: 'mcr.microsoft.com/azuredocs/containerapps-helloworld:latest' + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + containerAppEnvironment: ${{ env.TEST_NEW_CONTAINER_APP_ENV }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Delete created Azure Container App + if: ${{ always() }} + shell: bash + run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + + - name: Get customer ID for workspace to delete + if: ${{ always() }} + shell: bash + run: | + CUSTOMER_ID=$(az containerapp env show -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -n ${{ env.TEST_NEW_CONTAINER_APP_ENV }} --query 'properties.appLogsConfiguration.logAnalyticsConfiguration.customerId') + echo "CUSTOMER_ID=${CUSTOMER_ID}" >> $GITHUB_ENV + + - name: Get name of workspace to delete + if: ${{ always() }} + shell: bash + run: | + WORKSPACE_NAME=$(az monitor log-analytics workspace list -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} --query '[?customerId == `${{ env.CUSTOMER_ID }}`].name | [0]') + echo "WORKSPACE_NAME=${WORKSPACE_NAME}" >> $GITHUB_ENV + + - name: Delete created Azure Container App environment + if: ${{ always() }} + shell: bash + run: az containerapp env delete -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -n ${{ env.TEST_NEW_CONTAINER_APP_ENV }} -y + + - name: Delete created workspace + if: ${{ always() }} + shell: bash + run: az monitor log-analytics workspace delete -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -n ${{ env.WORKSPACE_NAME }} -y + + create-using-builder-yaml: + + name: 'Create app using builder with YAML configuration' + runs-on: ubuntu-latest + permissions: + id-token: write # This is required for requesting the OIDC JWT Token + timeout-minutes: 10 + + env: + TEST_IMAGE_TAG: 'bs-yaml-${{ github.run_id }}' + TEST_CONTAINER_APP_NAME: 'gh-ca-bs-yaml-${{ github.run_id }}' + TEST_YAML_FILE_PATH: '${{ github.workspace }}/yaml-samples/create-with-builder-simple.yaml' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Clone Oryx repository + uses: actions/checkout@v3 + with: + repository: microsoft/Oryx + path: oryx + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Update values in YAML configuration file + shell: pwsh + run: | + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$SUBSCRIPTION_ID$', '${{ vars.TEST_SUBSCRIPTION_ID }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$RESOURCE_GROUP$', '${{ vars.TEST_RESOURCE_GROUP_NAME }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$CONTAINER_APP_ENV$', '${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$FULL_ACR_NAME$', '${{ env.TEST_FULL_ACR_NAME }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$ACR_USERNAME$', '${{ secrets.TEST_REGISTRY_USERNAME }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$ACR_PASSWORD$', '${{ secrets.TEST_REGISTRY_PASSWORD }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$IMAGE_REPOSITORY$', '${{ env.TEST_IMAGE_REPOSITORY }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$IMAGE_TAG$', '${{ env.TEST_IMAGE_TAG }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + yamlConfigPath: ${{ env.TEST_YAML_FILE_PATH }} + appSourcePath: '${{ github.workspace }}/oryx/tests/SampleApps/DotNetCore/NetCore6PreviewWebApp' + acrName: ${{ vars.TEST_ACR_NAME }} + acrUsername: ${{ secrets.TEST_REGISTRY_USERNAME }} + acrPassword: ${{ secrets.TEST_REGISTRY_PASSWORD }} + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + imageToBuild: ${{ env.TEST_FULL_ACR_NAME }}/${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Delete created Azure Container App + if: ${{ always() }} + shell: bash + run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + + - name: Delete pushed image + if: ${{ always() }} + shell: bash + run: az acr repository delete -n ${{ vars.TEST_ACR_NAME }} -t ${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} -y + + create-using-image-yaml-linux: + + name: 'Create app using image with YAML configuration on Linux runner' + runs-on: ubuntu-latest + permissions: + id-token: write #This is required for requesting the OIDC JWT Token + timeout-minutes: 10 + + env: + TEST_CONTAINER_APP_NAME: 'gh-ca-bs-yaml-lin-${{ github.run_id }}' + TEST_YAML_FILE_PATH: '${{ github.workspace }}/yaml-samples/create-with-image-simple.yaml' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Clone Oryx repository + uses: actions/checkout@v3 + with: + repository: microsoft/Oryx + path: oryx + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Update values in YAML configuration file + shell: pwsh + run: | + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$SUBSCRIPTION_ID$', '${{ vars.TEST_SUBSCRIPTION_ID }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$RESOURCE_GROUP$', '${{ vars.TEST_RESOURCE_GROUP_NAME }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$CONTAINER_APP_ENV$', '${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + yamlConfigPath: ${{ env.TEST_YAML_FILE_PATH }} + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Delete created Azure Container App + if: ${{ always() }} + shell: bash + run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + + create-using-image-yaml-windows: + + name: 'Create app using image with YAML configuration on Windows runner' + runs-on: windows-latest + permissions: + id-token: write #This is required for requesting the OIDC JWT Token + timeout-minutes: 10 + + env: + TEST_CONTAINER_APP_NAME: 'gh-ca-bs-yaml-win-${{ github.run_id }}' + TEST_YAML_FILE_PATH: 'yaml-samples/create-with-image-simple.yaml' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Clone Oryx repository + uses: actions/checkout@v3 + with: + repository: microsoft/Oryx + path: oryx + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Update values in YAML configuration file + shell: pwsh + run: | + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$SUBSCRIPTION_ID$', '${{ vars.TEST_SUBSCRIPTION_ID }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$RESOURCE_GROUP$', '${{ vars.TEST_RESOURCE_GROUP_NAME }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$CONTAINER_APP_ENV$', '${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + yamlConfigPath: ${{ env.TEST_YAML_FILE_PATH }} + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Delete created Azure Container App + if: ${{ always() }} + shell: bash + run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + + update-using-builder: + + name: 'Update existing app using builder' + runs-on: ubuntu-latest + permissions: + id-token: write #This is required for requesting the OIDC JWT Token + timeout-minutes: 10 + + env: + TEST_IMAGE_TAG: 'bs-up-${{ github.run_id }}' + TEST_CONTAINER_APP_NAME: 'update-using-builder-app' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Clone Oryx repository + uses: actions/checkout@v3 + with: + repository: microsoft/Oryx + path: oryx + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + appSourcePath: '${{ github.workspace }}/oryx/tests/SampleApps/DotNetCore/NetCore6PreviewWebApp' + acrName: ${{ vars.TEST_ACR_NAME }} + acrUsername: ${{ secrets.TEST_REGISTRY_USERNAME }} + acrPassword: ${{ secrets.TEST_REGISTRY_PASSWORD }} + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + containerAppEnvironment: ${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + imageToBuild: ${{ env.TEST_FULL_ACR_NAME }}/${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Delete pushed image + if: ${{ always() }} + shell: bash + run: az acr repository delete -n ${{ vars.TEST_ACR_NAME }} -t ${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} -y + + - name: Update Container App with existing image + if: ${{ always() }} + shell: bash + run: az containerapp update -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -i mcr.microsoft.com/azuredocs/containerapps-helloworld:latest + + update-using-builder-and-internal-registry: + + name: 'Update existing app using builder and push to internal registry' + runs-on: ubuntu-latest + permissions: + id-token: write #This is required for requesting the OIDC JWT Token + timeout-minutes: 10 + + env: + TEST_IMAGE_TAG: 'bs-up-${{ github.run_id }}' + TEST_CONTAINER_APP_NAME: 'update-using-builder-app' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Clone Oryx repository + uses: actions/checkout@v3 + with: + repository: microsoft/Oryx + path: oryx + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + appSourcePath: '${{ github.workspace }}/oryx/tests/SampleApps/DotNetCore/NetCore6PreviewWebApp' + containerAppName: ${{ env.TEST_EXISTING_CONTAINER_APP }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NO_ACR_NAME }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Update Container App with existing image + if: ${{ always() }} + shell: bash + run: az containerapp update -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -i mcr.microsoft.com/azuredocs/containerapps-helloworld:latest + + update-using-image: + + name: 'Update app using image' + runs-on: ubuntu-latest + permissions: + id-token: write # This is required for requesting the OIDC JWT Token + timeout-minutes: 10 + + env: + TEST_CONTAINER_APP_NAME: 'update-using-image-app' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + imageToDeploy: 'mcr.microsoft.com/azuredocs/containerapps-helloworld:latest' + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + containerAppEnvironment: ${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + update-using-image-yaml: + + name: 'Update app using image with YAML configuration' + runs-on: ubuntu-latest + permissions: + id-token: write # This is required for requesting the OIDC JWT Token + timeout-minutes: 10 + + env: + TEST_CONTAINER_APP_NAME: 'update-using-image-yaml-app' + TEST_YAML_FILE_PATH: '${{ github.workspace }}/yaml-samples/update-with-image-simple.yaml' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Update values in YAML configuration file + shell: pwsh + run: | + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$SUBSCRIPTION_ID$', '${{ vars.TEST_SUBSCRIPTION_ID }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$RESOURCE_GROUP$', '${{ vars.TEST_RESOURCE_GROUP_NAME }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$CONTAINER_APP_ENV$', '${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + yamlConfigPath: ${{ env.TEST_YAML_FILE_PATH }} + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} \ No newline at end of file diff --git a/.github/workflows/run-validation.yml b/.github/workflows/run-validation.yml index a6d1e0a7..f708a330 100644 --- a/.github/workflows/run-validation.yml +++ b/.github/workflows/run-validation.yml @@ -18,6 +18,7 @@ env: jobs: create-using-builder: + name: 'Create app using builder' runs-on: ubuntu-latest timeout-minutes: 10 @@ -59,8 +60,14 @@ jobs: shell: bash run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + - name: Delete pushed image + if: ${{ always() }} + shell: bash + run: az acr repository delete -n ${{ vars.TEST_ACR_NAME }} -t ${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} -y + create-using-builder-and-internal-registry: + name: 'Create app using builder and push to internal registry' runs-on: ubuntu-latest timeout-minutes: 10 @@ -99,6 +106,7 @@ jobs: create-using-found-dockerfile: + name: 'Create app using found Dockerfile' runs-on: ubuntu-latest timeout-minutes: 10 @@ -140,7 +148,13 @@ jobs: shell: bash run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + - name: Delete pushed image + if: ${{ always() }} + shell: bash + run: az acr repository delete -n ${{ vars.TEST_ACR_NAME }} -t ${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} -y + create-using-provided-dockerfile: + name: 'Create app using provided Dockerfile' runs-on: ubuntu-latest timeout-minutes: 10 @@ -183,6 +197,12 @@ jobs: shell: bash run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + - name: Delete pushed image + if: ${{ always() }} + shell: bash + run: az acr repository delete -n ${{ vars.TEST_ACR_NAME }} -t ${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} -y + + create-using-image-linux: name: 'Create app using image on Linux runner' @@ -304,7 +324,70 @@ jobs: shell: bash run: az monitor log-analytics workspace delete -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -n ${{ env.WORKSPACE_NAME }} -y + + create-using-builder-yaml: + + name: 'Create app using builder with YAML configuration' + runs-on: ubuntu-latest + timeout-minutes: 10 + + env: + TEST_IMAGE_TAG: 'bs-yaml-${{ github.run_id }}' + TEST_CONTAINER_APP_NAME: 'gh-ca-bs-yaml-${{ github.run_id }}' + TEST_YAML_FILE_PATH: '${{ github.workspace }}/yaml-samples/create-with-builder-simple.yaml' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Clone Oryx repository + uses: actions/checkout@v3 + with: + repository: microsoft/Oryx + path: oryx + + - name: Log in to Azure + uses: azure/login@v1 + with: + creds: ${{ secrets.TEST_AZURE_CREDENTIALS }} + + - name: Update values in YAML configuration file + shell: pwsh + run: | + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$SUBSCRIPTION_ID$', '${{ vars.TEST_SUBSCRIPTION_ID }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$RESOURCE_GROUP$', '${{ vars.TEST_RESOURCE_GROUP_NAME }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$CONTAINER_APP_ENV$', '${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$FULL_ACR_NAME$', '${{ env.TEST_FULL_ACR_NAME }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$ACR_USERNAME$', '${{ secrets.TEST_REGISTRY_USERNAME }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$ACR_PASSWORD$', '${{ secrets.TEST_REGISTRY_PASSWORD }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$IMAGE_REPOSITORY$', '${{ env.TEST_IMAGE_REPOSITORY }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$IMAGE_TAG$', '${{ env.TEST_IMAGE_TAG }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + yamlConfigPath: ${{ env.TEST_YAML_FILE_PATH }} + appSourcePath: '${{ github.workspace }}/oryx/tests/SampleApps/DotNetCore/NetCore6PreviewWebApp' + acrName: ${{ vars.TEST_ACR_NAME }} + acrUsername: ${{ secrets.TEST_REGISTRY_USERNAME }} + acrPassword: ${{ secrets.TEST_REGISTRY_PASSWORD }} + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + imageToBuild: ${{ env.TEST_FULL_ACR_NAME }}/${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Delete created Azure Container App + if: ${{ always() }} + shell: bash + run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + + - name: Delete pushed image + if: ${{ always() }} + shell: bash + run: az acr repository delete -n ${{ vars.TEST_ACR_NAME }} -t ${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} -y + create-using-image-yaml-linux: + name: 'Create app using image with YAML configuration on Linux runner' runs-on: ubuntu-latest timeout-minutes: 10 @@ -349,6 +432,7 @@ jobs: run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y create-using-image-yaml-windows: + name: 'Create app using image with YAML configuration on Windows runner' runs-on: windows-latest timeout-minutes: 10 @@ -393,6 +477,7 @@ jobs: run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y update-using-builder: + name: 'Update existing app using builder' runs-on: ubuntu-latest timeout-minutes: 10 @@ -429,12 +514,18 @@ jobs: imageToBuild: ${{ env.TEST_FULL_ACR_NAME }}/${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + - name: Delete pushed image + if: ${{ always() }} + shell: bash + run: az acr repository delete -n ${{ vars.TEST_ACR_NAME }} -t ${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} -y + - name: Update Container App with existing image if: ${{ always() }} shell: bash run: az containerapp update -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -i mcr.microsoft.com/azuredocs/containerapps-helloworld:latest update-using-builder-and-internal-registry: + name: 'Update existing app using builder and push to internal registry' runs-on: ubuntu-latest timeout-minutes: 10 @@ -499,6 +590,7 @@ jobs: disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} update-using-image-yaml: + name: 'Update app using image with YAML configuration' runs-on: ubuntu-latest timeout-minutes: 10 diff --git a/azurecontainerapps.ts b/azurecontainerapps.ts index c55e2947..61b18824 100644 --- a/azurecontainerapps.ts +++ b/azurecontainerapps.ts @@ -31,17 +31,14 @@ export class azurecontainerapps { await this.authenticateAzureContainerRegistryAsync(); } - // Set up the Container App Image properties if it's not provided by the user. - this.setupContainerAppImageProperties(); + // Set up property to determine if the internal registry should be used + this.useInternalRegistry = this.util.isNullOrEmpty(this.registryUrl); - const useAzureContainerRegistry = !this.util.isNullOrEmpty(this.registryUrl) && this.registryUrl.endsWith('.azurecr.io'); - this.useInternalRegistry = this.util.isNullOrEmpty(this.registryUrl) && this.imageToBuild.startsWith(this.defaultRegistryServer); - - // Determine if the image should be built and pushed using the CLI - this.useCliToBuildAndPushImage = (useAzureContainerRegistry || this.useInternalRegistry); + // Set up property to trigger cloud build with 'up' command + this.shouldCreateOrUpdateContainerAppWithUp = !this.util.isNullOrEmpty(this.appSourcePath) && this.useInternalRegistry; // If the application source was provided, build a runnable application image from it - if (!this.useCliToBuildAndPushImage && !this.util.isNullOrEmpty(this.appSourcePath)) { + if (!this.useInternalRegistry && !this.util.isNullOrEmpty(this.appSourcePath)) { await this.buildAndPushImageAsync(); } @@ -107,9 +104,8 @@ export class azurecontainerapps { private static ingress: string; private static targetPort: string; private static shouldUseUpdateCommand: boolean; - private static useCliToBuildAndPushImage: boolean; - private static defaultRegistryServer: string = 'default/'; private static useInternalRegistry: boolean; + private static shouldCreateOrUpdateContainerAppWithUp: boolean; /** * Initializes the helpers used by this task. @@ -181,11 +177,11 @@ export class azurecontainerapps { /** * Sets up the Azure CLI to be used for this task by logging in to Azure with the provided service connection and - * setting the Azure CLI to dynamically install missing extensions. + * setting the Azure CLI to install missing extensions. */ private static async setupAzureCli() { - // Set the Azure CLI to dynamically install missing extensions - await this.util.setAzureCliDynamicInstall(); + // Set the Azure CLI to install missing extensions + await this.util.installAzureCliExtension(); } /** @@ -350,32 +346,27 @@ export class azurecontainerapps { // If telemetry is enabled, log that the previously built image scenario was targeted for this task this.telemetryHelper.setImageScenario(); } - /** - * Sets up the Container App Image properties if it's not provided by the user. - */ - private static setupContainerAppImageProperties() { - // Get the name of the image to build if it was provided, or generate it from build variables - this.imageToBuild = this.toolHelper.getInput('imageToBuild', false); - - if (this.util.isNullOrEmpty(this.imageToBuild)) { - const imageRepository = this.toolHelper.getDefaultImageRepository() - // Constructs the image to build based on the provided registry URL, image repository, build ID, and build number. - // If the registry URL is not provided or is empty, the default registry server is used; otherwise, the provided registry URL is used. - this.imageToBuild = this.util.isNullOrEmpty(this.registryUrl) ? `${this.defaultRegistryServer}${imageRepository}:${this.buildId}.${this.buildNumber}` : `${this.registryUrl}/${imageRepository}:${this.buildId}.${this.buildNumber}`; - this.toolHelper.writeInfo(`Default image to build: ${this.imageToBuild}`); - } - - // Get the name of the image to deploy if it was provided, or set it to the value of 'imageToBuild' - if (this.util.isNullOrEmpty(this.imageToDeploy)) { - this.imageToDeploy = this.imageToBuild; - this.toolHelper.writeInfo(`Default image to deploy: ${this.imageToDeploy}`); - } - } /** * Builds a runnable application image using a Dockerfile or the builder and pushes it to the Container Registry. */ private static async buildAndPushImageAsync() { + // Get the name of the image to build if it was provided, or generate it from build variables + this.imageToBuild = this.toolHelper.getInput('imageToBuild', false); + + if (this.util.isNullOrEmpty(this.imageToBuild)) { + const imageRepository = this.toolHelper.getDefaultImageRepository() + // Constructs the image to build based on the provided registry URL, image repository, build ID, and build number. + this.imageToBuild = `${this.registryUrl}/${imageRepository}:${this.buildId}.${this.buildNumber}`; + this.toolHelper.writeInfo(`Default image to build: ${this.imageToBuild}`); + } + + // Get the name of the image to deploy if it was provided, or set it to the value of 'imageToBuild' + if (this.util.isNullOrEmpty(this.imageToDeploy)) { + this.imageToDeploy = this.imageToBuild; + this.toolHelper.writeInfo(`Default image to deploy: ${this.imageToDeploy}`); + } + // Get Dockerfile to build, if provided, or check if one exists at the root of the provided application let dockerfilePath: string = this.toolHelper.getInput('dockerfilePath', false); if (this.util.isNullOrEmpty(dockerfilePath)) { @@ -538,25 +529,24 @@ export class azurecontainerapps { } } - if (!this.imageToDeploy.startsWith(this.defaultRegistryServer)) { + // Ensure '-i' argument and '--source' argument are not both provided + if (!this.util.isNullOrEmpty(this.imageToDeploy)) { this.commandLineArgs.push(`-i ${this.imageToDeploy}`); - } - - if (!this.util.isNullOrEmpty(this.appSourcePath) && this.useCliToBuildAndPushImage) { + } else if (this.shouldCreateOrUpdateContainerAppWithUp) { this.commandLineArgs.push(`--source ${this.appSourcePath}`); } + } /** * 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 (createOrUpdateContainerAppWithUp) { + } else if (this.shouldCreateOrUpdateContainerAppWithUp) { await this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs); } else { // Create the Container App from command line arguments @@ -573,7 +563,7 @@ export class azurecontainerapps { return; } - if (this.shouldUseUpdateCommand && !createOrUpdateContainerAppWithUp) { + if (this.shouldUseUpdateCommand && !this.shouldCreateOrUpdateContainerAppWithUp) { // 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); @@ -581,7 +571,7 @@ export class azurecontainerapps { // Update the Container App using the 'update' command await this.appHelper.updateContainerApp(this.containerAppName, this.resourceGroup, this.commandLineArgs); - } else if (createOrUpdateContainerAppWithUp) { + } else if (this.shouldCreateOrUpdateContainerAppWithUp) { await this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs); } else { // Update the Container App using the 'up' command diff --git a/dist/index.js b/dist/index.js index 4bb882ba..e072a57a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -21,7 +21,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { + while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { @@ -42,7 +42,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.__esModule = true; exports.azurecontainerapps = void 0; var fs = __nccwpck_require__(7147); var path = __nccwpck_require__(1017); @@ -56,7 +56,7 @@ var azurecontainerapps = /** @class */ (function () { } azurecontainerapps.runMain = function () { return __awaiter(this, void 0, void 0, function () { - var useAzureContainerRegistry, err_1; + var err_1; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -88,13 +88,11 @@ var azurecontainerapps = /** @class */ (function () { _a.sent(); _a.label = 7; case 7: - // Set up the Container App Image properties if it's not provided by the user. - this.setupContainerAppImageProperties(); - useAzureContainerRegistry = !this.util.isNullOrEmpty(this.registryUrl) && this.registryUrl.endsWith('.azurecr.io'); - this.useInternalRegistry = this.util.isNullOrEmpty(this.registryUrl) && this.imageToBuild.startsWith(this.defaultRegistryServer); - // Determine if the image should be built and pushed using the CLI - this.useCliToBuildAndPushImage = (useAzureContainerRegistry || this.useInternalRegistry); - if (!(!this.useCliToBuildAndPushImage && !this.util.isNullOrEmpty(this.appSourcePath))) return [3 /*break*/, 9]; + // Set up property to determine if the internal registry should be used + this.useInternalRegistry = this.util.isNullOrEmpty(this.registryUrl); + // Set up property to trigger cloud build with 'up' command + this.shouldCreateOrUpdateContainerAppWithUp = !this.util.isNullOrEmpty(this.appSourcePath) && this.useInternalRegistry; + if (!(!this.useInternalRegistry && !this.util.isNullOrEmpty(this.appSourcePath))) return [3 /*break*/, 9]; return [4 /*yield*/, this.buildAndPushImageAsync()]; case 8: _a.sent(); @@ -186,17 +184,17 @@ var azurecontainerapps = /** @class */ (function () { }; /** * Sets up the Azure CLI to be used for this task by logging in to Azure with the provided service connection and - * setting the Azure CLI to dynamically install missing extensions. + * setting the Azure CLI to install missing extensions. */ azurecontainerapps.setupAzureCli = function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - // Set the Azure CLI to dynamically install missing extensions - return [4 /*yield*/, this.util.setAzureCliDynamicInstall()]; + // Set the Azure CLI to install missing extensions + return [4 /*yield*/, this.util.installAzureCliExtension()]; case 1: - // Set the Azure CLI to dynamically install missing extensions + // Set the Azure CLI to install missing extensions _a.sent(); return [2 /*return*/]; } @@ -297,8 +295,8 @@ var azurecontainerapps = /** @class */ (function () { case 0: resourceGroup = this.toolHelper.getInput('resourceGroup', false); if (!this.util.isNullOrEmpty(resourceGroup)) return [3 /*break*/, 3]; - resourceGroup = "".concat(containerAppName, "-rg"); - this.toolHelper.writeInfo("Default resource group name: ".concat(resourceGroup)); + resourceGroup = containerAppName + "-rg"; + this.toolHelper.writeInfo("Default resource group name: " + resourceGroup); return [4 /*yield*/, this.appHelper.doesResourceGroupExist(resourceGroup)]; case 1: resourceGroupExists = _a.sent(); @@ -334,15 +332,15 @@ var azurecontainerapps = /** @class */ (function () { case 1: existingContainerAppEnvironment = _a.sent(); if (!this.util.isNullOrEmpty(existingContainerAppEnvironment)) { - this.toolHelper.writeInfo("Existing Container App environment found in resource group: ".concat(existingContainerAppEnvironment)); + this.toolHelper.writeInfo("Existing Container App environment found in resource group: " + existingContainerAppEnvironment); return [2 /*return*/, existingContainerAppEnvironment]; } _a.label = 2; case 2: // Generate the Container App environment name if it was not provided if (this.util.isNullOrEmpty(containerAppEnvironment)) { - containerAppEnvironment = "".concat(containerAppName, "-env"); - this.toolHelper.writeInfo("Default Container App environment name: ".concat(containerAppEnvironment)); + containerAppEnvironment = containerAppName + "-env"; + this.toolHelper.writeInfo("Default Container App environment name: " + containerAppEnvironment); } return [4 /*yield*/, this.appHelper.doesContainerAppEnvironmentExist(containerAppEnvironment, resourceGroup)]; case 3: @@ -367,15 +365,15 @@ var azurecontainerapps = /** @class */ (function () { case 0: this.registryUsername = this.toolHelper.getInput('acrUsername', false); this.registryPassword = this.toolHelper.getInput('acrPassword', false); - this.registryUrl = "".concat(this.acrName, ".azurecr.io"); + this.registryUrl = this.acrName + ".azurecr.io"; if (!(!this.util.isNullOrEmpty(this.registryUsername) && !this.util.isNullOrEmpty(this.registryPassword))) return [3 /*break*/, 2]; - this.toolHelper.writeInfo("Logging in to ACR instance \"".concat(this.acrName, "\" with username and password credentials")); + this.toolHelper.writeInfo("Logging in to ACR instance \"" + this.acrName + "\" with username and password credentials"); return [4 /*yield*/, this.registryHelper.loginContainerRegistryWithUsernamePassword(this.registryUrl, this.registryUsername, this.registryPassword)]; case 1: _a.sent(); return [3 /*break*/, 4]; case 2: - this.toolHelper.writeInfo("No ACR credentials provided; attempting to log in to ACR instance \"".concat(this.acrName, "\" with access token")); + this.toolHelper.writeInfo("No ACR credentials provided; attempting to log in to ACR instance \"" + this.acrName + "\" with access token"); return [4 /*yield*/, this.registryHelper.loginAcrWithAccessTokenAsync(this.acrName)]; case 3: _a.sent(); @@ -396,7 +394,7 @@ var azurecontainerapps = /** @class */ (function () { this.registryUsername = this.toolHelper.getInput('registryUsername', false); this.registryPassword = this.toolHelper.getInput('registryPassword', false); if (!(!this.util.isNullOrEmpty(this.registryUsername) && !this.util.isNullOrEmpty(this.registryPassword))) return [3 /*break*/, 2]; - this.toolHelper.writeInfo("Logging in to Container Registry \"".concat(this.registryUrl, "\" with username and password credentials")); + this.toolHelper.writeInfo("Logging in to Container Registry \"" + this.registryUrl + "\" with username and password credentials"); return [4 /*yield*/, this.registryHelper.loginContainerRegistryWithUsernamePassword(this.registryUrl, this.registryUsername, this.registryPassword)]; case 1: _a.sent(); @@ -413,34 +411,28 @@ var azurecontainerapps = /** @class */ (function () { // If telemetry is enabled, log that the previously built image scenario was targeted for this task this.telemetryHelper.setImageScenario(); }; - /** - * Sets up the Container App Image properties if it's not provided by the user. - */ - azurecontainerapps.setupContainerAppImageProperties = function () { - // Get the name of the image to build if it was provided, or generate it from build variables - this.imageToBuild = this.toolHelper.getInput('imageToBuild', false); - if (this.util.isNullOrEmpty(this.imageToBuild)) { - var imageRepository = this.toolHelper.getDefaultImageRepository(); - // Constructs the image to build based on the provided registry URL, image repository, build ID, and build number. - // If the registry URL is not provided or is empty, the default registry server is used; otherwise, the provided registry URL is used. - this.imageToBuild = this.util.isNullOrEmpty(this.registryUrl) ? "".concat(this.defaultRegistryServer).concat(imageRepository, ":").concat(this.buildId, ".").concat(this.buildNumber) : "".concat(this.registryUrl, "/").concat(imageRepository, ":").concat(this.buildId, ".").concat(this.buildNumber); - this.toolHelper.writeInfo("Default image to build: ".concat(this.imageToBuild)); - } - // Get the name of the image to deploy if it was provided, or set it to the value of 'imageToBuild' - if (this.util.isNullOrEmpty(this.imageToDeploy)) { - this.imageToDeploy = this.imageToBuild; - this.toolHelper.writeInfo("Default image to deploy: ".concat(this.imageToDeploy)); - } - }; /** * Builds a runnable application image using a Dockerfile or the builder and pushes it to the Container Registry. */ azurecontainerapps.buildAndPushImageAsync = function () { return __awaiter(this, void 0, void 0, function () { - var dockerfilePath, rootDockerfilePath; + var imageRepository, dockerfilePath, rootDockerfilePath; return __generator(this, function (_a) { switch (_a.label) { case 0: + // Get the name of the image to build if it was provided, or generate it from build variables + this.imageToBuild = this.toolHelper.getInput('imageToBuild', false); + if (this.util.isNullOrEmpty(this.imageToBuild)) { + imageRepository = this.toolHelper.getDefaultImageRepository(); + // Constructs the image to build based on the provided registry URL, image repository, build ID, and build number. + this.imageToBuild = this.registryUrl + "/" + imageRepository + ":" + this.buildId + "." + this.buildNumber; + this.toolHelper.writeInfo("Default image to build: " + this.imageToBuild); + } + // Get the name of the image to deploy if it was provided, or set it to the value of 'imageToBuild' + if (this.util.isNullOrEmpty(this.imageToDeploy)) { + this.imageToDeploy = this.imageToBuild; + this.toolHelper.writeInfo("Default image to deploy: " + this.imageToDeploy); + } dockerfilePath = this.toolHelper.getInput('dockerfilePath', false); if (!this.util.isNullOrEmpty(dockerfilePath)) return [3 /*break*/, 4]; this.toolHelper.writeInfo("No Dockerfile path provided; checking for Dockerfile at root of application source."); @@ -508,15 +500,15 @@ var azurecontainerapps = /** @class */ (function () { runtimeStackSplit = runtimeStack.split(':'); platformName = runtimeStackSplit[0] == "dotnetcore" ? "dotnet" : runtimeStackSplit[0]; platformVersion = runtimeStackSplit[1]; - environmentVariables.push("ORYX_PLATFORM_NAME=".concat(platformName)); - environmentVariables.push("ORYX_PLATFORM_VERSION=".concat(platformVersion)); + environmentVariables.push("ORYX_PLATFORM_NAME=" + platformName); + environmentVariables.push("ORYX_PLATFORM_VERSION=" + platformVersion); } builderStack = this.toolHelper.getInput('builderStack', false); // Set the target port on the image produced by the builder if (!this.util.isNullOrEmpty(this.targetPort)) { - environmentVariables.push("ORYX_RUNTIME_PORT=".concat(this.targetPort)); + environmentVariables.push("ORYX_RUNTIME_PORT=" + this.targetPort); } - this.toolHelper.writeInfo("Building image \"".concat(imageToBuild, "\" using the Oryx++ Builder")); + this.toolHelper.writeInfo("Building image \"" + imageToBuild + "\" using the Oryx++ Builder"); // Set the Oryx++ Builder as the default builder locally return [4 /*yield*/, this.appHelper.setDefaultBuilder()]; case 3: @@ -545,7 +537,7 @@ var azurecontainerapps = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - this.toolHelper.writeInfo("Building image \"".concat(imageToBuild, "\" using the provided Dockerfile")); + this.toolHelper.writeInfo("Building image \"" + imageToBuild + "\" using the provided Dockerfile"); return [4 /*yield*/, this.appHelper.createRunnableAppImageFromDockerfile(imageToBuild, appSourcePath, dockerfilePath)]; case 1: _a.sent(); @@ -573,7 +565,7 @@ var azurecontainerapps = /** @class */ (function () { // Pass the Container Registry credentials when creating a Container App or updating a Container App via the 'up' command if (!this.util.isNullOrEmpty(this.registryUrl) && !this.util.isNullOrEmpty(this.registryUsername) && !this.util.isNullOrEmpty(this.registryPassword) && (!this.containerAppExists || (this.containerAppExists && !this.shouldUseUpdateCommand))) { - this.commandLineArgs.push("--registry-server ".concat(this.registryUrl), "--registry-username ".concat(this.registryUsername), "--registry-password ".concat(this.registryPassword)); + this.commandLineArgs.push("--registry-server " + this.registryUrl, "--registry-username " + this.registryUsername, "--registry-password " + this.registryPassword); } // Determine default values only for the 'create' scenario to avoid overriding existing values for the 'update' scenario if (!this.containerAppExists) { @@ -581,7 +573,7 @@ var azurecontainerapps = /** @class */ (function () { // Set the ingress value to 'external' if it was not provided if (this.util.isNullOrEmpty(this.ingress)) { this.ingress = 'external'; - this.toolHelper.writeInfo("Default ingress value: ".concat(this.ingress)); + this.toolHelper.writeInfo("Default ingress value: " + this.ingress); } // Set the value of ingressEnabled to 'false' if ingress was provided as 'disabled' if (this.ingress == 'disabled') { @@ -595,12 +587,12 @@ var azurecontainerapps = /** @class */ (function () { // Set the target port to 80 if it was not provided if (this.util.isNullOrEmpty(this.targetPort)) { this.targetPort = '80'; - this.toolHelper.writeInfo("Default target port: ".concat(this.targetPort)); + this.toolHelper.writeInfo("Default target port: " + this.targetPort); } // Add the ingress value and target port to the optional arguments array // Note: this step should be skipped if we're updating an existing Container App (ingress is enabled via a separate command) - this.commandLineArgs.push("--ingress ".concat(this.ingress)); - this.commandLineArgs.push("--target-port ".concat(this.targetPort)); + this.commandLineArgs.push("--ingress " + this.ingress); + this.commandLineArgs.push("--target-port " + this.targetPort); } } var environmentVariables = this.toolHelper.getInput('environmentVariables', false); @@ -609,17 +601,18 @@ var azurecontainerapps = /** @class */ (function () { // The --replace-env-vars flag is only used for the 'update' command, // otherwise --env-vars is used for 'create' and 'up' if (this.shouldUseUpdateCommand) { - this.commandLineArgs.push("--replace-env-vars ".concat(environmentVariables)); + this.commandLineArgs.push("--replace-env-vars " + environmentVariables); } else { - this.commandLineArgs.push("--env-vars ".concat(environmentVariables)); + this.commandLineArgs.push("--env-vars " + environmentVariables); } } - if (!this.imageToDeploy.startsWith(this.defaultRegistryServer)) { - this.commandLineArgs.push("-i ".concat(this.imageToDeploy)); + // Ensure '-i' argument and '--source' argument are not both provided + if (!this.util.isNullOrEmpty(this.imageToDeploy)) { + this.commandLineArgs.push("-i " + this.imageToDeploy); } - if (!this.util.isNullOrEmpty(this.appSourcePath) && this.useCliToBuildAndPushImage) { - this.commandLineArgs.push("--source ".concat(this.appSourcePath)); + else if (this.shouldCreateOrUpdateContainerAppWithUp) { + this.commandLineArgs.push("--source " + this.appSourcePath); } }; /** @@ -627,11 +620,9 @@ 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 @@ -641,7 +632,7 @@ var azurecontainerapps = /** @class */ (function () { _a.sent(); return [3 /*break*/, 6]; case 2: - if (!createOrUpdateContainerAppWithUp) return [3 /*break*/, 4]; + if (!this.shouldCreateOrUpdateContainerAppWithUp) return [3 /*break*/, 4]; return [4 /*yield*/, this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs)]; case 3: _a.sent(); @@ -663,7 +654,7 @@ var azurecontainerapps = /** @class */ (function () { _a.sent(); return [2 /*return*/]; case 9: - if (!(this.shouldUseUpdateCommand && !createOrUpdateContainerAppWithUp)) return [3 /*break*/, 13]; + if (!(this.shouldUseUpdateCommand && !this.shouldCreateOrUpdateContainerAppWithUp)) 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: @@ -677,7 +668,7 @@ var azurecontainerapps = /** @class */ (function () { _a.sent(); return [3 /*break*/, 17]; case 13: - if (!createOrUpdateContainerAppWithUp) return [3 /*break*/, 15]; + if (!this.shouldCreateOrUpdateContainerAppWithUp) return [3 /*break*/, 15]; return [4 /*yield*/, this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs)]; case 14: _a.sent(); @@ -700,7 +691,6 @@ var azurecontainerapps = /** @class */ (function () { }); }); }; - azurecontainerapps.defaultRegistryServer = 'default/'; return azurecontainerapps; }()); exports.azurecontainerapps = azurecontainerapps; @@ -4681,7 +4671,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { + while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { @@ -4702,7 +4692,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.__esModule = true; exports.ContainerAppHelper = void 0; var path = __nccwpck_require__(1017); var os = __nccwpck_require__(2037); @@ -4735,13 +4725,13 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to create Container App with name \"".concat(containerAppName, "\" in resource group \"").concat(resourceGroup, "\"")); + toolHelper.writeDebug("Attempting to create Container App with name \"" + containerAppName + "\" in resource group \"" + resourceGroup + "\""); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command_1 = "az containerapp create -n ".concat(containerAppName, " -g ").concat(resourceGroup, " --environment ").concat(environment, " --output none"); + command_1 = "az containerapp create -n " + containerAppName + " -g " + resourceGroup + " --environment " + environment + " --output none"; optionalCmdArgs.forEach(function (val) { - command_1 += " ".concat(val); + command_1 += " " + val; }); return [4 /*yield*/, util.execute(command_1)]; case 2: @@ -4768,13 +4758,13 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to create Container App with name \"".concat(containerAppName, "\" in resource group \"").concat(resourceGroup, "\"")); + toolHelper.writeDebug("Attempting to create Container App with name \"" + containerAppName + "\" in resource group \"" + resourceGroup + "\""); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command_2 = "az containerapp up -n ".concat(containerAppName, " -g ").concat(resourceGroup, " -l northcentralusstage"); + command_2 = "az containerapp up -n " + containerAppName + " -g " + resourceGroup + " -l northcentralusstage"; optionalCmdArgs.forEach(function (val) { - command_2 += " ".concat(val); + command_2 += " " + val; }); return [4 /*yield*/, util.execute(command_2)]; case 2: @@ -4801,11 +4791,11 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to create Container App with name \"".concat(containerAppName, "\" in resource group \"").concat(resourceGroup, "\" from provided YAML \"").concat(yamlConfigPath, "\"")); + toolHelper.writeDebug("Attempting to create Container App with name \"" + containerAppName + "\" in resource group \"" + resourceGroup + "\" from provided YAML \"" + yamlConfigPath + "\""); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "az containerapp create -n ".concat(containerAppName, " -g ").concat(resourceGroup, " --yaml ").concat(yamlConfigPath, " --output none"); + command = "az containerapp create -n " + containerAppName + " -g " + resourceGroup + " --yaml " + yamlConfigPath + " --output none"; return [4 /*yield*/, util.execute(command)]; case 2: _a.sent(); @@ -4831,13 +4821,13 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to update Container App with name \"".concat(containerAppName, "\" in resource group \"").concat(resourceGroup, "\" ")); + toolHelper.writeDebug("Attempting to update Container App with name \"" + containerAppName + "\" in resource group \"" + resourceGroup + "\" "); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command_3 = "az containerapp update -n ".concat(containerAppName, " -g ").concat(resourceGroup, " --output none"); + command_3 = "az containerapp update -n " + containerAppName + " -g " + resourceGroup + " --output none"; optionalCmdArgs.forEach(function (val) { - command_3 += " ".concat(val); + command_3 += " " + val; }); return [4 /*yield*/, util.execute(command_3)]; case 2: @@ -4866,19 +4856,19 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to update Container App with name \"".concat(containerAppName, "\" in resource group \"").concat(resourceGroup, "\"")); + toolHelper.writeDebug("Attempting to update Container App with name \"" + containerAppName + "\" in resource group \"" + resourceGroup + "\""); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command_4 = "az containerapp up -n ".concat(containerAppName, " -g ").concat(resourceGroup); + command_4 = "az containerapp up -n " + containerAppName + " -g " + resourceGroup; optionalCmdArgs.forEach(function (val) { - command_4 += " ".concat(val); + command_4 += " " + val; }); if (!util.isNullOrEmpty(ingress)) { - command_4 += " --ingress ".concat(ingress); + command_4 += " --ingress " + ingress; } if (!util.isNullOrEmpty(targetPort)) { - command_4 += " --target-port ".concat(targetPort); + command_4 += " --target-port " + targetPort; } return [4 /*yield*/, util.execute(command_4)]; case 2: @@ -4905,11 +4895,11 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to update Container App with name \"".concat(containerAppName, "\" in resource group \"").concat(resourceGroup, "\" from provided YAML \"").concat(yamlConfigPath, "\"")); + toolHelper.writeDebug("Attempting to update Container App with name \"" + containerAppName + "\" in resource group \"" + resourceGroup + "\" from provided YAML \"" + yamlConfigPath + "\""); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "az containerapp update -n ".concat(containerAppName, " -g ").concat(resourceGroup, " --yaml ").concat(yamlConfigPath, " --output none"); + command = "az containerapp update -n " + containerAppName + " -g " + resourceGroup + " --yaml " + yamlConfigPath + " --output none"; return [4 /*yield*/, util.execute(command)]; case 2: _a.sent(); @@ -4935,11 +4925,11 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to determine if Container App with name \"".concat(containerAppName, "\" exists in resource group \"").concat(resourceGroup, "\"")); + toolHelper.writeDebug("Attempting to determine if Container App with name \"" + containerAppName + "\" exists in resource group \"" + resourceGroup + "\""); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "az containerapp show -n ".concat(containerAppName, " -g ").concat(resourceGroup, " -o none"); + command = "az containerapp show -n " + containerAppName + " -g " + resourceGroup + " -o none"; return [4 /*yield*/, util.execute(command)]; case 2: executionResult = _a.sent(); @@ -4965,11 +4955,11 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to determine if Container App Environment with name \"".concat(containerAppEnvironment, "\" exists in resource group \"").concat(resourceGroup, "\"")); + toolHelper.writeDebug("Attempting to determine if Container App Environment with name \"" + containerAppEnvironment + "\" exists in resource group \"" + resourceGroup + "\""); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "az containerapp env show -n ".concat(containerAppEnvironment, " -g ").concat(resourceGroup, " -o none"); + command = "az containerapp env show -n " + containerAppEnvironment + " -g " + resourceGroup + " -o none"; return [4 /*yield*/, util.execute(command)]; case 2: executionResult = _a.sent(); @@ -4994,11 +4984,11 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to determine if resource group \"".concat(resourceGroup, "\" exists")); + toolHelper.writeDebug("Attempting to determine if resource group \"" + resourceGroup + "\" exists"); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "az group show -n ".concat(resourceGroup, " -o none"); + command = "az group show -n " + resourceGroup + " -o none"; return [4 /*yield*/, util.execute(command)]; case 2: executionResult = _a.sent(); @@ -5052,11 +5042,11 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to create resource group \"".concat(name, "\" in location \"").concat(location, "\"")); + toolHelper.writeDebug("Attempting to create resource group \"" + name + "\" in location \"" + location + "\""); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "az group create -n ".concat(name, " -l ").concat(location); + command = "az group create -n " + name + " -l " + location; return [4 /*yield*/, util.execute(command)]; case 2: _a.sent(); @@ -5081,11 +5071,11 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to get the existing Container App Environment in resource group \"".concat(resourceGroup, "\"")); + toolHelper.writeDebug("Attempting to get the existing Container App Environment in resource group \"" + resourceGroup + "\""); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "az containerapp env list -g ".concat(resourceGroup, " --query \"[0].name\""); + command = "az containerapp env list -g " + resourceGroup + " --query \"[0].name\""; return [4 /*yield*/, util.execute(command)]; case 2: executionResult = _a.sent(); @@ -5112,13 +5102,13 @@ var ContainerAppHelper = /** @class */ (function () { switch (_a.label) { case 0: util = new Utility_1.Utility(); - toolHelper.writeDebug("Attempting to create Container App Environment with name \"".concat(name, "\" in resource group \"").concat(resourceGroup, "\"")); + toolHelper.writeDebug("Attempting to create Container App Environment with name \"" + name + "\" in resource group \"" + resourceGroup + "\""); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "az containerapp env create -n ".concat(name, " -g ").concat(resourceGroup); + command = "az containerapp env create -n " + name + " -g " + resourceGroup; if (!util.isNullOrEmpty(location)) { - command += " -l ".concat(location); + command += " -l " + location; } return [4 /*yield*/, util.execute(command)]; case 2: @@ -5144,11 +5134,11 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to disable ingress for Container App with name \"".concat(name, "\" in resource group \"").concat(resourceGroup, "\"")); + toolHelper.writeDebug("Attempting to disable ingress for Container App with name \"" + name + "\" in resource group \"" + resourceGroup + "\""); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "az containerapp ingress disable -n ".concat(name, " -g ").concat(resourceGroup); + command = "az containerapp ingress disable -n " + name + " -g " + resourceGroup; return [4 /*yield*/, util.execute(command)]; case 2: _a.sent(); @@ -5176,11 +5166,11 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to set the Container Registry details for Container App with name \"".concat(name, "\" in resource group \"").concat(resourceGroup, "\"")); + toolHelper.writeDebug("Attempting to set the Container Registry details for Container App with name \"" + name + "\" in resource group \"" + resourceGroup + "\""); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "az containerapp registry set -n ".concat(name, " -g ").concat(resourceGroup, " --server ").concat(registryUrl, " --username ").concat(registryUsername, " --password ").concat(registryPassword); + command = "az containerapp registry set -n " + name + " -g " + resourceGroup + " --server " + registryUrl + " --username " + registryUsername + " --password " + registryPassword; return [4 /*yield*/, util.execute(command)]; case 2: _a.sent(); @@ -5214,28 +5204,28 @@ var ContainerAppHelper = /** @class */ (function () { couldBuildImage = false; _loop_1 = function (builderImage) { var command_5, err_16; - return __generator(this, function (_b) { - switch (_b.label) { + return __generator(this, function (_a) { + switch (_a.label) { case 0: if (!util.isNullOrEmpty(builderStack) && !builderImage.includes(builderStack)) { return [2 /*return*/, "continue"]; } - toolHelper.writeDebug("Attempting to create a runnable application image with name \"".concat(imageToDeploy, "\" using the Oryx++ Builder \"").concat(builderImage, "\"")); - _b.label = 1; + toolHelper.writeDebug("Attempting to create a runnable application image with name \"" + imageToDeploy + "\" using the Oryx++ Builder \"" + builderImage + "\""); + _a.label = 1; case 1: - _b.trys.push([1, 3, , 4]); - command_5 = "build ".concat(imageToDeploy, " --path ").concat(appSourcePath, " --builder ").concat(builderImage, " --env ").concat(telemetryArg); + _a.trys.push([1, 3, , 4]); + command_5 = "build " + imageToDeploy + " --path " + appSourcePath + " --builder " + builderImage + " --env " + telemetryArg; environmentVariables.forEach(function (envVar) { - command_5 += " --env ".concat(envVar); + command_5 += " --env " + envVar; }); - return [4 /*yield*/, util.execute("".concat(PACK_CMD, " ").concat(command_5))]; + return [4 /*yield*/, util.execute(PACK_CMD + " " + command_5)]; case 2: - _b.sent(); + _a.sent(); couldBuildImage = true; return [2 /*return*/, "break"]; case 3: - err_16 = _b.sent(); - toolHelper.writeWarning("Unable to run 'pack build' command to produce runnable application image: ".concat(err_16.message)); + err_16 = _a.sent(); + toolHelper.writeWarning("Unable to run 'pack build' command to produce runnable application image: " + err_16.message); return [3 /*break*/, 4]; case 4: return [2 /*return*/]; } @@ -5281,15 +5271,15 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to create a runnable application image from the provided/found Dockerfile \"".concat(dockerfilePath, "\" with image name \"").concat(imageToDeploy, "\"")); + toolHelper.writeDebug("Attempting to create a runnable application image from the provided/found Dockerfile \"" + dockerfilePath + "\" with image name \"" + imageToDeploy + "\""); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "docker build --file ".concat(dockerfilePath, " ").concat(appSourcePath, " --tag ").concat(imageToDeploy); + command = "docker build --file " + dockerfilePath + " " + appSourcePath + " --tag " + imageToDeploy; return [4 /*yield*/, util.execute(command)]; case 2: _a.sent(); - toolHelper.writeDebug("Successfully created runnable application image from the provided/found Dockerfile \"".concat(dockerfilePath, "\" with image name \"").concat(imageToDeploy, "\"")); + toolHelper.writeDebug("Successfully created runnable application image from the provided/found Dockerfile \"" + dockerfilePath + "\" with image name \"" + imageToDeploy + "\""); return [3 /*break*/, 4]; case 3: err_17 = _a.sent(); @@ -5315,7 +5305,7 @@ var ContainerAppHelper = /** @class */ (function () { _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "docker run --rm -v ".concat(appSourcePath, ":/app ").concat(ORYX_CLI_IMAGE, " /bin/bash -c \"oryx dockerfile /app | head -n 1 | sed 's/ARG RUNTIME=//' >> /app/oryx-runtime.txt\""); + command = "docker run --rm -v " + appSourcePath + ":/app " + ORYX_CLI_IMAGE + " /bin/bash -c \"oryx dockerfile /app | head -n 1 | sed 's/ARG RUNTIME=//' >> /app/oryx-runtime.txt\""; return [4 /*yield*/, util.execute(command) // Read the temp file to get the runtime stack into a variable ]; @@ -5325,14 +5315,14 @@ var ContainerAppHelper = /** @class */ (function () { runtimeStack = fs.promises.readFile(oryxRuntimeTxtPath_1, 'utf8').then(function (data) { var lines = data.split('\n'); return lines[0]; - }).catch(function (err) { + })["catch"](function (err) { toolHelper.writeError(err.message); throw err; }); // Delete the temp file fs.unlink(oryxRuntimeTxtPath_1, function (err) { if (err) { - toolHelper.writeWarning("Unable to delete the temporary file \"".concat(oryxRuntimeTxtPath_1, "\". Error: ").concat(err.message)); + toolHelper.writeWarning("Unable to delete the temporary file \"" + oryxRuntimeTxtPath_1 + "\". Error: " + err.message); } }); return [2 /*return*/, runtimeStack]; @@ -5359,8 +5349,8 @@ var ContainerAppHelper = /** @class */ (function () { _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "config default-builder ".concat(ORYX_BUILDER_IMAGES[0]); - return [4 /*yield*/, util.execute("".concat(PACK_CMD, " ").concat(command))]; + command = "config default-builder " + ORYX_BUILDER_IMAGES[0]; + return [4 /*yield*/, util.execute(PACK_CMD + " " + command)]; case 2: _a.sent(); return [3 /*break*/, 4]; @@ -5392,22 +5382,22 @@ var ContainerAppHelper = /** @class */ (function () { if (IS_WINDOWS_AGENT) { packZipDownloadUri = 'https://github.com/buildpacks/pack/releases/download/v0.31.0/pack-v0.31.0-windows.zip'; packZipDownloadFilePath = path.join(PACK_CMD, 'pack-windows.zip'); - command = "New-Item -ItemType Directory -Path ".concat(PACK_CMD, " -Force | Out-Null; Invoke-WebRequest -Uri ").concat(packZipDownloadUri, " -OutFile ").concat(packZipDownloadFilePath, "; Expand-Archive -LiteralPath ").concat(packZipDownloadFilePath, " -DestinationPath ").concat(PACK_CMD, "; Remove-Item -Path ").concat(packZipDownloadFilePath); + command = "New-Item -ItemType Directory -Path " + PACK_CMD + " -Force | Out-Null; Invoke-WebRequest -Uri " + packZipDownloadUri + " -OutFile " + packZipDownloadFilePath + "; Expand-Archive -LiteralPath " + packZipDownloadFilePath + " -DestinationPath " + PACK_CMD + "; Remove-Item -Path " + packZipDownloadFilePath; commandLine = 'pwsh'; } else { tgzSuffix = os.platform() == 'darwin' ? 'macos' : 'linux'; - command = "(curl -sSL \"https://github.com/buildpacks/pack/releases/download/v0.31.0/pack-v0.31.0-".concat(tgzSuffix, ".tgz\" | ") + + command = "(curl -sSL \"https://github.com/buildpacks/pack/releases/download/v0.31.0/pack-v0.31.0-" + tgzSuffix + ".tgz\" | " + 'tar -C /usr/local/bin/ --no-same-owner -xzv pack)'; commandLine = 'bash'; } - return [4 /*yield*/, util.execute("".concat(commandLine, " -c \"").concat(command, "\""))]; + return [4 /*yield*/, util.execute(commandLine + " -c \"" + command + "\"")]; case 2: _a.sent(); return [3 /*break*/, 4]; case 3: err_20 = _a.sent(); - toolHelper.writeError("Unable to install the pack CLI. Error: ".concat(err_20.message)); + toolHelper.writeError("Unable to install the pack CLI. Error: " + err_20.message); throw err_20; case 4: return [2 /*return*/]; } @@ -5427,14 +5417,14 @@ var ContainerAppHelper = /** @class */ (function () { _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "".concat(PACK_CMD, " config experimental true"); + command = PACK_CMD + " config experimental true"; return [4 /*yield*/, util.execute(command)]; case 2: _a.sent(); return [3 /*break*/, 4]; case 3: err_21 = _a.sent(); - toolHelper.writeError("Unable to enable experimental features for the pack CLI: ".concat(err_21.message)); + toolHelper.writeError("Unable to enable experimental features for the pack CLI: " + err_21.message); throw err_21; case 4: return [2 /*return*/]; } @@ -5468,7 +5458,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { + while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { @@ -5489,7 +5479,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.__esModule = true; exports.ContainerRegistryHelper = void 0; var os = __nccwpck_require__(2037); var Utility_1 = __nccwpck_require__(2135); @@ -5511,17 +5501,17 @@ var ContainerRegistryHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to log in to Container Registry instance\"".concat(registryUrl, "\" with username and password credentials")); + toolHelper.writeDebug("Attempting to log in to Container Registry instance\"" + registryUrl + "\" with username and password credentials"); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - return [4 /*yield*/, util.execute("docker login --password-stdin --username ".concat(registryUsername, " ").concat(registryUrl), [], Buffer.from(registryPassword))]; + return [4 /*yield*/, util.execute("docker login --password-stdin --username " + registryUsername + " " + registryUrl, [], Buffer.from(registryPassword))]; case 2: _a.sent(); return [3 /*break*/, 4]; case 3: err_1 = _a.sent(); - toolHelper.writeError("Failed to log in to Container Registry instance \"".concat(registryUrl, "\" with username and password credentials")); + toolHelper.writeError("Failed to log in to Container Registry instance \"" + registryUrl + "\" with username and password credentials"); throw err_1; case 4: return [2 /*return*/]; } @@ -5539,18 +5529,18 @@ var ContainerRegistryHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to log in to ACR instance \"".concat(acrName, "\" with access token")); + toolHelper.writeDebug("Attempting to log in to ACR instance \"" + acrName + "\" with access token"); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); commandLine = os.platform() === 'win32' ? 'pwsh' : 'bash'; - return [4 /*yield*/, util.execute("".concat(commandLine, " -c \"CA_ADO_TASK_ACR_ACCESS_TOKEN=$(az acr login --name ").concat(acrName, " --output json --expose-token --only-show-errors | jq -r '.accessToken'); docker login ").concat(acrName, ".azurecr.io -u 00000000-0000-0000-0000-000000000000 -p $CA_ADO_TASK_ACR_ACCESS_TOKEN > /dev/null 2>&1\""))]; + return [4 /*yield*/, util.execute(commandLine + " -c \"CA_ADO_TASK_ACR_ACCESS_TOKEN=$(az acr login --name " + acrName + " --output json --expose-token --only-show-errors | jq -r '.accessToken'); docker login " + acrName + ".azurecr.io -u 00000000-0000-0000-0000-000000000000 -p $CA_ADO_TASK_ACR_ACCESS_TOKEN > /dev/null 2>&1\"")]; case 2: _a.sent(); return [3 /*break*/, 4]; case 3: err_2 = _a.sent(); - toolHelper.writeError("Failed to log in to ACR instance \"".concat(acrName, "\" with access token")); + toolHelper.writeError("Failed to log in to ACR instance \"" + acrName + "\" with access token"); throw err_2; case 4: return [2 /*return*/]; } @@ -5567,17 +5557,17 @@ var ContainerRegistryHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to push image \"".concat(imageToPush, "\" to Container Registry")); + toolHelper.writeDebug("Attempting to push image \"" + imageToPush + "\" to Container Registry"); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - return [4 /*yield*/, util.execute("docker push ".concat(imageToPush))]; + return [4 /*yield*/, util.execute("docker push " + imageToPush)]; case 2: _a.sent(); return [3 /*break*/, 4]; case 3: err_3 = _a.sent(); - toolHelper.writeError("Failed to push image \"".concat(imageToPush, "\" to Container Registry. Error: ").concat(err_3.message)); + toolHelper.writeError("Failed to push image \"" + imageToPush + "\" to Container Registry. Error: " + err_3.message); throw err_3; case 4: return [2 /*return*/]; } @@ -5611,7 +5601,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { + while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { @@ -5632,7 +5622,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.__esModule = true; exports.GitHubActionsToolHelper = void 0; var core = __nccwpck_require__(3195); var io = __nccwpck_require__(9529); @@ -5674,7 +5664,7 @@ var GitHubActionsToolHelper = /** @class */ (function () { }, stderr: function (data) { stderr_1 += data.toString(); - }, + } }, input: inputOptions }; @@ -5710,10 +5700,10 @@ var GitHubActionsToolHelper = /** @class */ (function () { return io.which(tool, check); }; GitHubActionsToolHelper.prototype.getDefaultContainerAppName = function (containerAppName) { - containerAppName = "gh-action-app-".concat(this.getBuildId(), "-").concat(this.getBuildNumber()); + containerAppName = "gh-action-app-" + this.getBuildId() + "-" + this.getBuildNumber(); // Replace all '.' characters with '-' characters in the Container App name containerAppName = containerAppName.replace(/\./gi, "-"); - this.writeInfo("Default Container App name: ".concat(containerAppName)); + this.writeInfo("Default Container App name: " + containerAppName); return containerAppName; }; GitHubActionsToolHelper.prototype.getTelemetryArg = function () { @@ -5752,7 +5742,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { + while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { @@ -5773,7 +5763,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.__esModule = true; exports.TelemetryHelper = void 0; var Utility_1 = __nccwpck_require__(2135); var GitHubActionsToolHelper_1 = __nccwpck_require__(3185); @@ -5838,24 +5828,24 @@ var TelemetryHelper = /** @class */ (function () { _a.trys.push([1, 3, , 4]); resultArg = ''; if (!util.isNullOrEmpty(this.result)) { - resultArg = "--property result=".concat(this.result); + resultArg = "--property result=" + this.result; } scenarioArg = ''; if (!util.isNullOrEmpty(this.scenario)) { - scenarioArg = "--property scenario=".concat(this.scenario); + scenarioArg = "--property scenario=" + this.scenario; } errorMessageArg = ''; if (!util.isNullOrEmpty(this.errorMessage)) { - errorMessageArg = "--property errorMessage=".concat(this.errorMessage); + errorMessageArg = "--property errorMessage=" + this.errorMessage; } eventName = toolHelper.getEventName(); - return [4 /*yield*/, util.execute("docker run --rm ".concat(ORYX_CLI_IMAGE, " /bin/bash -c \"oryx telemetry --event-name ").concat(eventName, " --processing-time ").concat(taskLengthMilliseconds, " ").concat(resultArg, " ").concat(scenarioArg, " ").concat(errorMessageArg, "\""))]; + return [4 /*yield*/, util.execute("docker run --rm " + ORYX_CLI_IMAGE + " /bin/bash -c \"oryx telemetry --event-name " + eventName + " --processing-time " + taskLengthMilliseconds + " " + resultArg + " " + scenarioArg + " " + errorMessageArg + "\"")]; case 2: _a.sent(); return [3 /*break*/, 4]; case 3: err_1 = _a.sent(); - toolHelper.writeWarning("Skipping telemetry logging due to the following exception: ".concat(err_1.message)); + toolHelper.writeWarning("Skipping telemetry logging due to the following exception: " + err_1.message); return [3 /*break*/, 4]; case 4: return [2 /*return*/]; } @@ -5889,7 +5879,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { + while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { @@ -5910,7 +5900,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.__esModule = true; exports.Utility = void 0; // Note: This file is used to define utility functions that can be used across the project. var GitHubActionsToolHelper_1 = __nccwpck_require__(3185); @@ -5934,9 +5924,9 @@ var Utility = /** @class */ (function () { }); }; /** - * Sets the Azure CLI to dynamically install extensions that are missing. + * Sets the Azure CLI to install the containerapp extension. */ - Utility.prototype.setAzureCliDynamicInstall = function () { + Utility.prototype.installAzureCliExtension = function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { diff --git a/src/Utility.ts b/src/Utility.ts index e8391aaf..b5e2659b 100644 --- a/src/Utility.ts +++ b/src/Utility.ts @@ -15,9 +15,9 @@ export class Utility { } /** - * Sets the Azure CLI to dynamically install extensions that are missing. + * Sets the Azure CLI to install the containerapp extension. */ - public async setAzureCliDynamicInstall() { + public async installAzureCliExtension() { await this.execute(`az extension add --name containerapp --upgrade`); } From 6d61150a2ae9535f06e21816028d8c865964013b Mon Sep 17 00:00:00 2001 From: snehapar9 Date: Thu, 9 Nov 2023 13:13:02 -0800 Subject: [PATCH 03/12] Test oidc --- azurecontainerapps.ts | 2 +- dist/index.js | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/azurecontainerapps.ts b/azurecontainerapps.ts index 61b18824..e5c2985b 100644 --- a/azurecontainerapps.ts +++ b/azurecontainerapps.ts @@ -181,7 +181,7 @@ export class azurecontainerapps { */ private static async setupAzureCli() { // Set the Azure CLI to install missing extensions - await this.util.installAzureCliExtension(); + // await this.util.installAzureCliExtension(); } /** diff --git a/dist/index.js b/dist/index.js index e072a57a..3ee20ab5 100644 --- a/dist/index.js +++ b/dist/index.js @@ -189,15 +189,7 @@ var azurecontainerapps = /** @class */ (function () { azurecontainerapps.setupAzureCli = function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { - switch (_a.label) { - case 0: - // Set the Azure CLI to install missing extensions - return [4 /*yield*/, this.util.installAzureCliExtension()]; - case 1: - // Set the Azure CLI to install missing extensions - _a.sent(); - return [2 /*return*/]; - } + return [2 /*return*/]; }); }); }; From 821a725dfc50d5dc5b7604ce196a2d2843f5f219 Mon Sep 17 00:00:00 2001 From: snehapar9 Date: Thu, 9 Nov 2023 13:38:58 -0800 Subject: [PATCH 04/12] Add --debug --- dist/index.js | 2 +- src/ContainerAppHelper.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 3ee20ab5..1bbf84e7 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4754,7 +4754,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 + " -l northcentralusstage"; + command_2 = "az containerapp up -n " + containerAppName + " -g " + resourceGroup + " -l northcentralusstage --debug"; optionalCmdArgs.forEach(function (val) { command_2 += " " + val; }); diff --git a/src/ContainerAppHelper.ts b/src/ContainerAppHelper.ts index 3c691d57..5644b681 100644 --- a/src/ContainerAppHelper.ts +++ b/src/ContainerAppHelper.ts @@ -57,7 +57,7 @@ export class ContainerAppHelper { 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} -l northcentralusstage`; + let command = `az containerapp up -n ${containerAppName} -g ${resourceGroup} -l northcentralusstage --debug`; optionalCmdArgs.forEach(function (val: string) { command += ` ${val}`; }); From 572e093213a109db0818c762013bac8675e68f83 Mon Sep 17 00:00:00 2001 From: snehapar9 Date: Thu, 9 Nov 2023 14:49:39 -0800 Subject: [PATCH 05/12] Target `update` flow --- azurecontainerapps.ts | 2 +- dist/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/azurecontainerapps.ts b/azurecontainerapps.ts index e5c2985b..26cd0592 100644 --- a/azurecontainerapps.ts +++ b/azurecontainerapps.ts @@ -563,7 +563,7 @@ export class azurecontainerapps { return; } - if (this.shouldUseUpdateCommand && !this.shouldCreateOrUpdateContainerAppWithUp) { + if (this.shouldUseUpdateCommand) { // 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); diff --git a/dist/index.js b/dist/index.js index 1bbf84e7..250b5181 100644 --- a/dist/index.js +++ b/dist/index.js @@ -646,7 +646,7 @@ var azurecontainerapps = /** @class */ (function () { _a.sent(); return [2 /*return*/]; case 9: - if (!(this.shouldUseUpdateCommand && !this.shouldCreateOrUpdateContainerAppWithUp)) return [3 /*break*/, 13]; + if (!this.shouldUseUpdateCommand) 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: From c92c9fee65a32d5f1237b90dbe6cbffa7a934050 Mon Sep 17 00:00:00 2001 From: snehapar9 Date: Thu, 9 Nov 2023 17:16:58 -0800 Subject: [PATCH 06/12] Hard code location to westus2 --- dist/index.js | 2 +- src/ContainerAppHelper.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 250b5181..bfc29e42 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4754,7 +4754,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 + " -l northcentralusstage --debug"; + command_2 = "az containerapp up -n " + containerAppName + " -g " + resourceGroup + " -l westus2 --debug"; optionalCmdArgs.forEach(function (val) { command_2 += " " + val; }); diff --git a/src/ContainerAppHelper.ts b/src/ContainerAppHelper.ts index 5644b681..74883f44 100644 --- a/src/ContainerAppHelper.ts +++ b/src/ContainerAppHelper.ts @@ -57,7 +57,7 @@ export class ContainerAppHelper { 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} -l northcentralusstage --debug`; + let command = `az containerapp up -n ${containerAppName} -g ${resourceGroup} -l westus2 --debug`; optionalCmdArgs.forEach(function (val: string) { command += ` ${val}`; }); From d7e56184f9212e83bb0581bf65051802141fa7f8 Mon Sep 17 00:00:00 2001 From: snehapar9 Date: Thu, 9 Nov 2023 17:26:22 -0800 Subject: [PATCH 07/12] Target `up` flow --- azurecontainerapps.ts | 2 +- dist/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/azurecontainerapps.ts b/azurecontainerapps.ts index 26cd0592..e5c2985b 100644 --- a/azurecontainerapps.ts +++ b/azurecontainerapps.ts @@ -563,7 +563,7 @@ export class azurecontainerapps { return; } - if (this.shouldUseUpdateCommand) { + if (this.shouldUseUpdateCommand && !this.shouldCreateOrUpdateContainerAppWithUp) { // 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); diff --git a/dist/index.js b/dist/index.js index bfc29e42..5278cae3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -646,7 +646,7 @@ var azurecontainerapps = /** @class */ (function () { _a.sent(); return [2 /*return*/]; case 9: - if (!this.shouldUseUpdateCommand) return [3 /*break*/, 13]; + if (!(this.shouldUseUpdateCommand && !this.shouldCreateOrUpdateContainerAppWithUp)) 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: From 969843d923f3e9e477975aa91748485282a2571c Mon Sep 17 00:00:00 2001 From: snehapar9 Date: Thu, 9 Nov 2023 18:10:40 -0800 Subject: [PATCH 08/12] Change location eastus --- dist/index.js | 2 +- src/ContainerAppHelper.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 5278cae3..ac69f186 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4754,7 +4754,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 + " -l westus2 --debug"; + command_2 = "az containerapp up -n " + containerAppName + " -g " + resourceGroup + " -l eastus --debug"; optionalCmdArgs.forEach(function (val) { command_2 += " " + val; }); diff --git a/src/ContainerAppHelper.ts b/src/ContainerAppHelper.ts index 74883f44..d4493559 100644 --- a/src/ContainerAppHelper.ts +++ b/src/ContainerAppHelper.ts @@ -57,7 +57,7 @@ export class ContainerAppHelper { 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} -l westus2 --debug`; + let command = `az containerapp up -n ${containerAppName} -g ${resourceGroup} -l eastus --debug`; optionalCmdArgs.forEach(function (val: string) { command += ` ${val}`; }); From bb9db59a85a80d22919e839d259195b8100e992d Mon Sep 17 00:00:00 2001 From: snehapar9 Date: Thu, 9 Nov 2023 18:46:27 -0800 Subject: [PATCH 09/12] hardcode eastus location --- azurecontainerapps.ts | 2 +- dist/index.js | 34 +++++++++++++++------------------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/azurecontainerapps.ts b/azurecontainerapps.ts index e5c2985b..6e01094d 100644 --- a/azurecontainerapps.ts +++ b/azurecontainerapps.ts @@ -196,7 +196,7 @@ export class azurecontainerapps { this.containerAppName = this.getContainerAppName(); // Get the location to deploy resources to, if provided, or use the default location - this.location = await this.getLocation(); + this.location = 'eastus'; // Get the resource group to deploy to if it was provided, or generate it from the Container App name this.resourceGroup = await this.getOrCreateResourceGroup(this.containerAppName, this.location); diff --git a/dist/index.js b/dist/index.js index ac69f186..01fc63a3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -202,37 +202,33 @@ var azurecontainerapps = /** @class */ (function () { */ azurecontainerapps.setupResources = function () { return __awaiter(this, void 0, void 0, function () { - var _a, _b, _c, _d; - return __generator(this, function (_e) { - switch (_e.label) { + var _a, _b, _c; + return __generator(this, function (_d) { + switch (_d.label) { case 0: // Get the Container App name if it was provided, or generate it from build variables this.containerAppName = this.getContainerAppName(); // Get the location to deploy resources to, if provided, or use the default location + this.location = 'eastus'; + // Get the resource group to deploy to if it was provided, or generate it from the Container App name _a = this; - return [4 /*yield*/, this.getLocation()]; + return [4 /*yield*/, this.getOrCreateResourceGroup(this.containerAppName, this.location)]; case 1: - // Get the location to deploy resources to, if provided, or use the default location - _a.location = _e.sent(); // Get the resource group to deploy to if it was provided, or generate it from the Container App name + _a.resourceGroup = _d.sent(); + // Determine if the Container App currently exists _b = this; - return [4 /*yield*/, this.getOrCreateResourceGroup(this.containerAppName, this.location)]; + return [4 /*yield*/, this.appHelper.doesContainerAppExist(this.containerAppName, this.resourceGroup)]; case 2: - // Get the resource group to deploy to if it was provided, or generate it from the Container App name - _b.resourceGroup = _e.sent(); // Determine if the Container App currently exists + _b.containerAppExists = _d.sent(); + if (!!this.containerAppExists) return [3 /*break*/, 4]; _c = this; - return [4 /*yield*/, this.appHelper.doesContainerAppExist(this.containerAppName, this.resourceGroup)]; - case 3: - // Determine if the Container App currently exists - _c.containerAppExists = _e.sent(); - if (!!this.containerAppExists) return [3 /*break*/, 5]; - _d = this; return [4 /*yield*/, this.getOrCreateContainerAppEnvironment(this.containerAppName, this.resourceGroup, this.location)]; - case 4: - _d.containerAppEnvironment = _e.sent(); - _e.label = 5; - case 5: return [2 /*return*/]; + case 3: + _c.containerAppEnvironment = _d.sent(); + _d.label = 4; + case 4: return [2 /*return*/]; } }); }); From e32282756c89efa66b96c74dc6b676c646588c6c Mon Sep 17 00:00:00 2001 From: snehapar9 Date: Fri, 10 Nov 2023 13:08:56 -0800 Subject: [PATCH 10/12] Remove location from up --- dist/index.js | 2 +- src/ContainerAppHelper.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 01fc63a3..4dfb0f87 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4750,7 +4750,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 + " -l eastus --debug"; + command_2 = "az containerapp up -n " + containerAppName + " -g " + resourceGroup + " --debug"; optionalCmdArgs.forEach(function (val) { command_2 += " " + val; }); diff --git a/src/ContainerAppHelper.ts b/src/ContainerAppHelper.ts index d4493559..45ecb5ff 100644 --- a/src/ContainerAppHelper.ts +++ b/src/ContainerAppHelper.ts @@ -57,7 +57,7 @@ export class ContainerAppHelper { 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} -l eastus --debug`; + let command = `az containerapp up -n ${containerAppName} -g ${resourceGroup} --debug`; optionalCmdArgs.forEach(function (val: string) { command += ` ${val}`; }); From a3b28dd8c83bae754dccb87958cdba96f8b9bc17 Mon Sep 17 00:00:00 2001 From: snehapar9 Date: Fri, 10 Nov 2023 17:59:09 -0800 Subject: [PATCH 11/12] Hard code west us for testing --- dist/index.js | 2 +- src/ContainerAppHelper.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 4dfb0f87..a6cb72cb 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4750,7 +4750,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 + " --debug"; + command_2 = "az containerapp up -n " + containerAppName + " -g " + resourceGroup + " -l westus2 --debug"; optionalCmdArgs.forEach(function (val) { command_2 += " " + val; }); diff --git a/src/ContainerAppHelper.ts b/src/ContainerAppHelper.ts index 45ecb5ff..74883f44 100644 --- a/src/ContainerAppHelper.ts +++ b/src/ContainerAppHelper.ts @@ -57,7 +57,7 @@ export class ContainerAppHelper { 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} --debug`; + let command = `az containerapp up -n ${containerAppName} -g ${resourceGroup} -l westus2 --debug`; optionalCmdArgs.forEach(function (val: string) { command += ` ${val}`; }); From 4bae842b9a7c2c960d9d87fb14d32332a4493946 Mon Sep 17 00:00:00 2001 From: snehapar9 Date: Fri, 10 Nov 2023 21:49:48 -0800 Subject: [PATCH 12/12] Set location dynamically --- azurecontainerapps.ts | 13 ++- dist/index.js | 206 +++++++++++++++++++++++++------------- src/ContainerAppHelper.ts | 33 +++++- 3 files changed, 181 insertions(+), 71 deletions(-) diff --git a/azurecontainerapps.ts b/azurecontainerapps.ts index 6e01094d..73556a4d 100644 --- a/azurecontainerapps.ts +++ b/azurecontainerapps.ts @@ -196,7 +196,7 @@ export class azurecontainerapps { this.containerAppName = this.getContainerAppName(); // Get the location to deploy resources to, if provided, or use the default location - this.location = 'eastus'; + this.location = await this.getLocation(); // Get the resource group to deploy to if it was provided, or generate it from the Container App name this.resourceGroup = await this.getOrCreateResourceGroup(this.containerAppName, this.location); @@ -233,6 +233,12 @@ export class azurecontainerapps { // Set deployment location, if provided let location: string = this.toolHelper.getInput('location', false); + let doesContainerAppExist = await this.appHelper.doesContainerAppExist(this.containerAppName, this.resourceGroup); + if (doesContainerAppExist) { + var environmentId = await this.appHelper.getExistingContainerAppEnvironmentId(this.containerAppName); + var environmentName = environmentId.split("/").pop(); + location = await this.appHelper.getExistingContainerAppEnvironmentLocation(environmentName); + } // If no location was provided, use the default location for the Container App service if (this.util.isNullOrEmpty(location)) { location = await this.appHelper.getDefaultContainerAppLocation(); @@ -304,6 +310,9 @@ export class azurecontainerapps { await this.appHelper.createContainerAppEnvironment(containerAppEnvironment, resourceGroup, location); } + // Set default location to the location of the Container App environment + this.location = await this.appHelper.getExistingContainerAppEnvironmentLocation(containerAppEnvironment); + return containerAppEnvironment; } @@ -547,7 +556,7 @@ export class azurecontainerapps { // Create the Container App from the YAML configuration file await this.appHelper.createContainerAppFromYaml(this.containerAppName, this.resourceGroup, this.yamlConfigPath); } 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 { // Create the Container App from command line arguments await this.appHelper.createContainerApp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.commandLineArgs); diff --git a/dist/index.js b/dist/index.js index a6cb72cb..6a0fd679 100644 --- a/dist/index.js +++ b/dist/index.js @@ -202,33 +202,37 @@ var azurecontainerapps = /** @class */ (function () { */ azurecontainerapps.setupResources = function () { return __awaiter(this, void 0, void 0, function () { - var _a, _b, _c; - return __generator(this, function (_d) { - switch (_d.label) { + var _a, _b, _c, _d; + return __generator(this, function (_e) { + switch (_e.label) { case 0: // Get the Container App name if it was provided, or generate it from build variables this.containerAppName = this.getContainerAppName(); // Get the location to deploy resources to, if provided, or use the default location - this.location = 'eastus'; - // Get the resource group to deploy to if it was provided, or generate it from the Container App name _a = this; - return [4 /*yield*/, this.getOrCreateResourceGroup(this.containerAppName, this.location)]; + return [4 /*yield*/, this.getLocation()]; case 1: + // Get the location to deploy resources to, if provided, or use the default location + _a.location = _e.sent(); // Get the resource group to deploy to if it was provided, or generate it from the Container App name - _a.resourceGroup = _d.sent(); - // Determine if the Container App currently exists _b = this; - return [4 /*yield*/, this.appHelper.doesContainerAppExist(this.containerAppName, this.resourceGroup)]; + return [4 /*yield*/, this.getOrCreateResourceGroup(this.containerAppName, this.location)]; case 2: + // Get the resource group to deploy to if it was provided, or generate it from the Container App name + _b.resourceGroup = _e.sent(); // Determine if the Container App currently exists - _b.containerAppExists = _d.sent(); - if (!!this.containerAppExists) return [3 /*break*/, 4]; _c = this; - return [4 /*yield*/, this.getOrCreateContainerAppEnvironment(this.containerAppName, this.resourceGroup, this.location)]; + return [4 /*yield*/, this.appHelper.doesContainerAppExist(this.containerAppName, this.resourceGroup)]; case 3: - _c.containerAppEnvironment = _d.sent(); - _d.label = 4; - case 4: return [2 /*return*/]; + // Determine if the Container App currently exists + _c.containerAppExists = _e.sent(); + if (!!this.containerAppExists) return [3 /*break*/, 5]; + _d = this; + return [4 /*yield*/, this.getOrCreateContainerAppEnvironment(this.containerAppName, this.resourceGroup, this.location)]; + case 4: + _d.containerAppEnvironment = _e.sent(); + _e.label = 5; + case 5: return [2 /*return*/]; } }); }); @@ -252,17 +256,30 @@ var azurecontainerapps = /** @class */ (function () { */ azurecontainerapps.getLocation = function () { return __awaiter(this, void 0, void 0, function () { - var location; + var location, doesContainerAppExist, environmentId, environmentName; return __generator(this, function (_a) { switch (_a.label) { case 0: location = this.toolHelper.getInput('location', false); - if (!this.util.isNullOrEmpty(location)) return [3 /*break*/, 2]; - return [4 /*yield*/, this.appHelper.getDefaultContainerAppLocation()]; + return [4 /*yield*/, this.appHelper.doesContainerAppExist(this.containerAppName, this.resourceGroup)]; case 1: + doesContainerAppExist = _a.sent(); + if (!doesContainerAppExist) return [3 /*break*/, 4]; + return [4 /*yield*/, this.appHelper.getExistingContainerAppEnvironmentId(this.containerAppName)]; + case 2: + environmentId = _a.sent(); + environmentName = environmentId.split("/").pop(); + return [4 /*yield*/, this.appHelper.getExistingContainerAppEnvironmentLocation(environmentName)]; + case 3: location = _a.sent(); - _a.label = 2; - case 2: return [2 /*return*/, location]; + _a.label = 4; + case 4: + if (!this.util.isNullOrEmpty(location)) return [3 /*break*/, 6]; + return [4 /*yield*/, this.appHelper.getDefaultContainerAppLocation()]; + case 5: + location = _a.sent(); + _a.label = 6; + case 6: return [2 /*return*/, location]; } }); }); @@ -310,20 +327,20 @@ var azurecontainerapps = /** @class */ (function () { */ azurecontainerapps.getOrCreateContainerAppEnvironment = function (containerAppName, resourceGroup, location) { return __awaiter(this, void 0, void 0, function () { - var containerAppEnvironment, existingContainerAppEnvironment, containerAppEnvironmentExists; - return __generator(this, function (_a) { - switch (_a.label) { + var containerAppEnvironment, existingContainerAppEnvironment, containerAppEnvironmentExists, _a; + return __generator(this, function (_b) { + switch (_b.label) { case 0: containerAppEnvironment = this.toolHelper.getInput('containerAppEnvironment', false); if (!this.util.isNullOrEmpty(containerAppEnvironment)) return [3 /*break*/, 2]; return [4 /*yield*/, this.appHelper.getExistingContainerAppEnvironment(resourceGroup)]; case 1: - existingContainerAppEnvironment = _a.sent(); + existingContainerAppEnvironment = _b.sent(); if (!this.util.isNullOrEmpty(existingContainerAppEnvironment)) { this.toolHelper.writeInfo("Existing Container App environment found in resource group: " + existingContainerAppEnvironment); return [2 /*return*/, existingContainerAppEnvironment]; } - _a.label = 2; + _b.label = 2; case 2: // Generate the Container App environment name if it was not provided if (this.util.isNullOrEmpty(containerAppEnvironment)) { @@ -332,13 +349,20 @@ var azurecontainerapps = /** @class */ (function () { } return [4 /*yield*/, this.appHelper.doesContainerAppEnvironmentExist(containerAppEnvironment, resourceGroup)]; case 3: - containerAppEnvironmentExists = _a.sent(); + containerAppEnvironmentExists = _b.sent(); if (!!containerAppEnvironmentExists) return [3 /*break*/, 5]; return [4 /*yield*/, this.appHelper.createContainerAppEnvironment(containerAppEnvironment, resourceGroup, location)]; case 4: - _a.sent(); - _a.label = 5; - case 5: return [2 /*return*/, containerAppEnvironment]; + _b.sent(); + _b.label = 5; + case 5: + // Set default location to the location of the Container App environment + _a = this; + return [4 /*yield*/, this.appHelper.getExistingContainerAppEnvironmentLocation(containerAppEnvironment)]; + case 6: + // Set default location to the location of the Container App environment + _a.location = _b.sent(); + return [2 /*return*/, containerAppEnvironment]; } }); }); @@ -621,7 +645,7 @@ var azurecontainerapps = /** @class */ (function () { return [3 /*break*/, 6]; case 2: if (!this.shouldCreateOrUpdateContainerAppWithUp) return [3 /*break*/, 4]; - 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 3: _a.sent(); return [3 /*break*/, 6]; @@ -4740,7 +4764,7 @@ var ContainerAppHelper = /** @class */ (function () { * @param resourceGroup - the resource group that the Container App is found in * @param optionalCmdArgs - a set of optional command line arguments */ - ContainerAppHelper.prototype.createOrUpdateContainerAppWithUp = function (containerAppName, resourceGroup, optionalCmdArgs) { + ContainerAppHelper.prototype.createOrUpdateContainerAppWithUp = function (containerAppName, resourceGroup, optionalCmdArgs, location) { return __awaiter(this, void 0, void 0, function () { var command_2, err_2; return __generator(this, function (_a) { @@ -4750,7 +4774,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 + " -l westus2 --debug"; + command_2 = "az containerapp up -n " + containerAppName + " -g " + resourceGroup + " -l " + location + " --debug"; optionalCmdArgs.forEach(function (val) { command_2 += " " + val; }); @@ -5077,6 +5101,54 @@ var ContainerAppHelper = /** @class */ (function () { }); }); }; + /** + * Gets the location of an existing Container App Environment + */ + ContainerAppHelper.prototype.getExistingContainerAppEnvironmentLocation = function (environmentName) { + 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\""; + return [4 /*yield*/, util.execute(command)]; + case 1: + executionResult = _a.sent(); + return [2 /*return*/, executionResult.exitCode === 0 ? executionResult.stdout : null]; + case 2: + err_13 = _a.sent(); + toolHelper.writeInfo(err_13.message); + return [2 /*return*/, null]; + case 3: return [2 /*return*/]; + } + }); + }); + }; + /** + * Gets the environment Id of an existing Container App + */ + ContainerAppHelper.prototype.getExistingContainerAppEnvironmentId = function (containerAppName) { + 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\""; + return [4 /*yield*/, util.execute(command)]; + case 1: + executionResult = _a.sent(); + return [2 /*return*/, executionResult.exitCode === 0 ? executionResult.stdout : null]; + case 2: + err_14 = _a.sent(); + toolHelper.writeInfo(err_14.message); + return [2 /*return*/, null]; + case 3: return [2 /*return*/]; + } + }); + }); + }; /** * Creates a new Azure Container App Environment in the provided resource group. * @param name - the name of the Container App Environment @@ -5085,7 +5157,7 @@ var ContainerAppHelper = /** @class */ (function () { */ ContainerAppHelper.prototype.createContainerAppEnvironment = function (name, resourceGroup, location) { return __awaiter(this, void 0, void 0, function () { - var util, command, err_13; + var util, command, err_15; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -5103,9 +5175,9 @@ var ContainerAppHelper = /** @class */ (function () { _a.sent(); return [3 /*break*/, 4]; case 3: - err_13 = _a.sent(); - toolHelper.writeError(err_13.message); - throw err_13; + err_15 = _a.sent(); + toolHelper.writeError(err_15.message); + throw err_15; case 4: return [2 /*return*/]; } }); @@ -5118,7 +5190,7 @@ var ContainerAppHelper = /** @class */ (function () { */ ContainerAppHelper.prototype.disableContainerAppIngress = function (name, resourceGroup) { return __awaiter(this, void 0, void 0, function () { - var command, err_14; + var command, err_16; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -5132,9 +5204,9 @@ var ContainerAppHelper = /** @class */ (function () { _a.sent(); return [3 /*break*/, 4]; case 3: - err_14 = _a.sent(); - toolHelper.writeError(err_14.message); - throw err_14; + err_16 = _a.sent(); + toolHelper.writeError(err_16.message); + throw err_16; case 4: return [2 /*return*/]; } }); @@ -5150,7 +5222,7 @@ var ContainerAppHelper = /** @class */ (function () { */ ContainerAppHelper.prototype.updateContainerAppRegistryDetails = function (name, resourceGroup, registryUrl, registryUsername, registryPassword) { return __awaiter(this, void 0, void 0, function () { - var command, err_15; + var command, err_17; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -5164,9 +5236,9 @@ var ContainerAppHelper = /** @class */ (function () { _a.sent(); return [3 /*break*/, 4]; case 3: - err_15 = _a.sent(); - toolHelper.writeError(err_15.message); - throw err_15; + err_17 = _a.sent(); + toolHelper.writeError(err_17.message); + throw err_17; case 4: return [2 /*return*/]; } }); @@ -5191,7 +5263,7 @@ var ContainerAppHelper = /** @class */ (function () { } couldBuildImage = false; _loop_1 = function (builderImage) { - var command_5, err_16; + var command_5, err_18; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -5212,8 +5284,8 @@ var ContainerAppHelper = /** @class */ (function () { couldBuildImage = true; return [2 /*return*/, "break"]; case 3: - err_16 = _a.sent(); - toolHelper.writeWarning("Unable to run 'pack build' command to produce runnable application image: " + err_16.message); + err_18 = _a.sent(); + toolHelper.writeWarning("Unable to run 'pack build' command to produce runnable application image: " + err_18.message); return [3 /*break*/, 4]; case 4: return [2 /*return*/]; } @@ -5255,7 +5327,7 @@ var ContainerAppHelper = /** @class */ (function () { */ ContainerAppHelper.prototype.createRunnableAppImageFromDockerfile = function (imageToDeploy, appSourcePath, dockerfilePath) { return __awaiter(this, void 0, void 0, function () { - var command, err_17; + var command, err_19; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -5270,9 +5342,9 @@ var ContainerAppHelper = /** @class */ (function () { toolHelper.writeDebug("Successfully created runnable application image from the provided/found Dockerfile \"" + dockerfilePath + "\" with image name \"" + imageToDeploy + "\""); return [3 /*break*/, 4]; case 3: - err_17 = _a.sent(); - toolHelper.writeError(err_17.message); - throw err_17; + err_19 = _a.sent(); + toolHelper.writeError(err_19.message); + throw err_19; case 4: return [2 /*return*/]; } }); @@ -5285,7 +5357,7 @@ var ContainerAppHelper = /** @class */ (function () { */ ContainerAppHelper.prototype.determineRuntimeStackAsync = function (appSourcePath) { return __awaiter(this, void 0, void 0, function () { - var command, oryxRuntimeTxtPath_1, runtimeStack, err_18; + var command, oryxRuntimeTxtPath_1, runtimeStack, err_20; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -5315,9 +5387,9 @@ var ContainerAppHelper = /** @class */ (function () { }); return [2 /*return*/, runtimeStack]; case 3: - err_18 = _a.sent(); - toolHelper.writeError(err_18.message); - throw err_18; + err_20 = _a.sent(); + toolHelper.writeError(err_20.message); + throw err_20; case 4: return [2 /*return*/]; } }); @@ -5329,7 +5401,7 @@ var ContainerAppHelper = /** @class */ (function () { */ ContainerAppHelper.prototype.setDefaultBuilder = function () { return __awaiter(this, void 0, void 0, function () { - var command, err_19; + var command, err_21; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -5343,9 +5415,9 @@ var ContainerAppHelper = /** @class */ (function () { _a.sent(); return [3 /*break*/, 4]; case 3: - err_19 = _a.sent(); - toolHelper.writeError(err_19.message); - throw err_19; + err_21 = _a.sent(); + toolHelper.writeError(err_21.message); + throw err_21; case 4: return [2 /*return*/]; } }); @@ -5357,7 +5429,7 @@ var ContainerAppHelper = /** @class */ (function () { */ ContainerAppHelper.prototype.installPackCliAsync = function () { return __awaiter(this, void 0, void 0, function () { - var command, commandLine, packZipDownloadUri, packZipDownloadFilePath, tgzSuffix, err_20; + var command, commandLine, packZipDownloadUri, packZipDownloadFilePath, tgzSuffix, err_22; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -5384,9 +5456,9 @@ var ContainerAppHelper = /** @class */ (function () { _a.sent(); return [3 /*break*/, 4]; case 3: - err_20 = _a.sent(); - toolHelper.writeError("Unable to install the pack CLI. Error: " + err_20.message); - throw err_20; + err_22 = _a.sent(); + toolHelper.writeError("Unable to install the pack CLI. Error: " + err_22.message); + throw err_22; case 4: return [2 /*return*/]; } }); @@ -5397,7 +5469,7 @@ var ContainerAppHelper = /** @class */ (function () { */ ContainerAppHelper.prototype.enablePackCliExperimentalFeaturesAsync = function () { return __awaiter(this, void 0, void 0, function () { - var command, err_21; + var command, err_23; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -5411,9 +5483,9 @@ var ContainerAppHelper = /** @class */ (function () { _a.sent(); return [3 /*break*/, 4]; case 3: - err_21 = _a.sent(); - toolHelper.writeError("Unable to enable experimental features for the pack CLI: " + err_21.message); - throw err_21; + err_23 = _a.sent(); + toolHelper.writeError("Unable to enable experimental features for the pack CLI: " + err_23.message); + throw err_23; case 4: return [2 /*return*/]; } }); diff --git a/src/ContainerAppHelper.ts b/src/ContainerAppHelper.ts index 74883f44..31ed9f14 100644 --- a/src/ContainerAppHelper.ts +++ b/src/ContainerAppHelper.ts @@ -54,10 +54,11 @@ export class ContainerAppHelper { public async createOrUpdateContainerAppWithUp( containerAppName: string, resourceGroup: string, - optionalCmdArgs: string[]) { + optionalCmdArgs: string[], + location: 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} -l westus2 --debug`; + let command = `az containerapp up -n ${containerAppName} -g ${resourceGroup} -l ${location} --debug`; optionalCmdArgs.forEach(function (val: string) { command += ` ${val}`; }); @@ -270,6 +271,34 @@ export class ContainerAppHelper { } } + /** + * Gets the location of an existing Container App Environment + */ + public async getExistingContainerAppEnvironmentLocation(environmentName: string) { + try { + let command = `az containerapp env show -n ${environmentName} --query "[0].location"` + let executionResult = await util.execute(command); + return executionResult.exitCode === 0 ? executionResult.stdout : null; + } catch (err) { + toolHelper.writeInfo(err.message); + return null; + } + } + + /** + * Gets the environment Id of an existing Container App + */ + public async getExistingContainerAppEnvironmentId(containerAppName: string) { + try { + let command = `az containerapp show -n ${containerAppName} --query "[0].properties.environmentId"` + let executionResult = await util.execute(command); + return executionResult.exitCode === 0 ? executionResult.stdout : null; + } catch (err) { + toolHelper.writeInfo(err.message); + return null; + } + } + /** * Creates a new Azure Container App Environment in the provided resource group. * @param name - the name of the Container App Environment