diff --git a/.github/workflows/docker-build-and-push.yml b/.github/workflows/docker-build-and-push.yml index 6cd52c784..1590336cc 100644 --- a/.github/workflows/docker-build-and-push.yml +++ b/.github/workflows/docker-build-and-push.yml @@ -24,7 +24,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - - name: Log in to Azure Container Registry + - name: Log in to Azure Container Registry - External Registry if: ${{ github.ref_name == 'main' }} uses: azure/docker-login@v2 with: @@ -32,8 +32,8 @@ jobs: username: ${{ secrets.ACR_USERNAME }} password: ${{ secrets.ACR_PASSWORD }} - - name: Log in to Azure Container Registry (Dev/Demo/Dependabotchanges) - if: ${{ github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'dependabotchanges' }} + - name: Log in to Azure Container Registry (Main/Dev/Demo/Dependabotchanges) - Internal Registry + if: ${{ github.ref_name == 'main' ||github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'dependabotchanges' }} uses: azure/docker-login@v2 with: login-server: ${{ secrets.ACR_DEV_LOGIN_SERVER }} @@ -46,7 +46,13 @@ jobs: - name: Get registry id: registry - run: echo "registry=${{ github.ref_name == 'main' && secrets.ACR_LOGIN_SERVER || secrets.ACR_DEV_LOGIN_SERVER }}" >> $GITHUB_OUTPUT + run: | + if [[ "${{ github.ref_name }}" == "main" ]]; then + echo "ext_registry=${{ secrets.ACR_LOGIN_SERVER }}" >> $GITHUB_OUTPUT + echo "int_registry=${{ secrets.ACR_DEV_LOGIN_SERVER }}" >> $GITHUB_OUTPUT + else + echo "int_registry=${{ secrets.ACR_DEV_LOGIN_SERVER }}" >> $GITHUB_OUTPUT + fi - name: Determine Tag Name Based on Branch id: determine_tag @@ -61,15 +67,26 @@ jobs: echo "tagname=dependabotchanges" >> $GITHUB_OUTPUT else echo "tagname=default" >> $GITHUB_OUTPUT - fi - - name: Build Docker Image and optionally push + - name: Build Docker Image and optionally push - Internal Registry uses: docker/build-push-action@v6 with: context: . file: WebApp.Dockerfile push: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'dependabotchanges' }} tags: | - ${{ steps.registry.outputs.registry }}/webapp:${{ steps.determine_tag.outputs.tagname }} - ${{ steps.registry.outputs.registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }} + ${{ steps.registry.outputs.int_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }} + ${{ steps.registry.outputs.int_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }} + + - name: Build Docker Image and optionally push - External Registry + if: ${{ github.ref_name == 'main' }} + uses: docker/build-push-action@v6 + with: + context: . + file: WebApp.Dockerfile + push: ${{github.ref_name == 'main' }} + tags: | + ${{ steps.registry.outputs.ext_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }} + ${{ steps.registry.outputs.ext_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }} + diff --git a/docs/container_registry_migration.md b/docs/container_registry_migration.md new file mode 100644 index 000000000..f78784716 --- /dev/null +++ b/docs/container_registry_migration.md @@ -0,0 +1,81 @@ +# Guide: Migrating Azure Web App Service to a New Container Registry + +## Overview + +### Current Problem: +- The **Document Generator Container Image** is being published in the **External ACR** (Azure Container Registry). + +### Goal: +- The goal is to **migrate container images** from various applications to a common **CSA CTO Production Azure Container Registry**, ensuring all the different images are consolidated in one centralized location. + +--- + +## Step-by-Step Guide: Migrating Azure Web App Service to a New Container Registry + +This guide will help you seamlessly switch the container registry for your **Azure Web App Service** from Azure Container Registry (ACR) to the new registry **`byocgacontainerreg`**. + +Follow the steps below to ensure a smooth migration. + +### Prerequisites: +Before you begin, ensure you have the following: +- Access to the **Azure Portal**. +- The **container image** in the new registry is ready and accessible. + +--- + +### Step 1: Obtain Details for the New Registry + +Before you begin, ensure you have the following information: +- **Registry URL**: The URL of the new registry (`https://byocgacontainerreg.azurecr.io`). +- **Image Name and Tag**: The full name and tag of the image you want to use: + - **Web App Image**: `webapp:latest` +--- + +### Step 2: Update Azure Web App Service Configuration Using Azure Portal + +1. **Log in to Azure Portal**: + - Open [Azure Portal](https://portal.azure.com/). + +2. **Locate Your Resource Group and Web App Service**: + - Navigate to resource group which you have created for Document Generator. + - Navigate to **Web App Service**: From the list of resources, find and select **App Service** + +3. **Go to the Deployment Center**: + - In the left-hand menu, click on **Deployment**. + + ![Resource Menu](images/resource_menu.png) + + +4. **Update Image Source**: + - Change the **Registry Source** to **Private**. + - Set the **Server URL** to the new container registry (`https://byocgacontainerreg.azurecr.io`), as shown in the screenshot below. + - Set the **Full Image name** to the relevant image name and tag: + - For Web App: `webapp:latest` + + ![Deployment Center](images/deployment_center.png) + +5. **Save Changes**: + - Click **Save** to save the configuration. + +--- + +### Step 3: Restart the Web App Service + +After updating the configuration, restart your **Web App Service** to apply the changes: + +1. In the **Web App Service overview page**, click on **Restart**. +2. Confirm the restart operation. + +--- + +### Step 8: Validate the Deployment + +1. **Access Your Web App**: + - Open the **Web App URL** in a browser to ensure it’s running correctly. +--- + +By following these steps, your **Azure Web App Service** will now use the new container from the **Document Generator registry**. + +For further assistance, feel free to reach out to your support team or log an issue on GitHub. + +--- diff --git a/docs/images/deployment_center.png b/docs/images/deployment_center.png new file mode 100644 index 000000000..834f6091d Binary files /dev/null and b/docs/images/deployment_center.png differ diff --git a/docs/images/resource_menu.png b/docs/images/resource_menu.png new file mode 100644 index 000000000..8d59d533f Binary files /dev/null and b/docs/images/resource_menu.png differ diff --git a/infra/main.bicep b/infra/main.bicep index 60e511be4..b8fabf3a1 100644 --- a/infra/main.bicep +++ b/infra/main.bicep @@ -166,7 +166,7 @@ param AzureOpenAIStopSequence string = '\n' @description('Whether or not to stream responses from Azure OpenAI? True or False.') param AzureOpenAIStream bool = true -var WebAppImageName = 'DOCKER|acrbyocga.azurecr.io/webapp:latest' +var WebAppImageName = 'DOCKER|byocgacontainerreg.azurecr.io/webapp:latest' var cosmosdb_database_name = 'db_conversation_history' var cosmosdb_container_name = 'conversations' var roleDefinitionId = '00000000-0000-0000-0000-000000000002' diff --git a/infra/main.json b/infra/main.json index 7c75b526e..1a047a4b7 100644 --- a/infra/main.json +++ b/infra/main.json @@ -5,14 +5,25 @@ "_generator": { "name": "bicep", "version": "0.33.93.31351", - "templateHash": "896617532796464630" + "templateHash": "7005910716688710298" } }, "parameters": { + "environmentName": { + "type": "string", + "minLength": 3, + "maxLength": 10, + "metadata": { + "description": "A unique prefix for all resources in this deployment. This should be 3-10 characters long:" + } + }, "HostingPlanName": { "type": "string", "defaultValue": "[guid(resourceGroup().id)]", "metadata": { + "azd": { + "type": "location" + }, "description": "Name of App Service plan" } }, @@ -263,7 +274,7 @@ } }, "variables": { - "WebAppImageName": "DOCKER|acrbyocga.azurecr.io/webapp:latest", + "WebAppImageName": "DOCKER|byocgacontainerreg.azurecr.io/webapp:latest", "cosmosdb_database_name": "db_conversation_history", "cosmosdb_container_name": "conversations", "roleDefinitionId": "00000000-0000-0000-0000-000000000002",