Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions .github/workflows/docker-build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ 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:
login-server: ${{ secrets.ACR_LOGIN_SERVER }}
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 }}
Expand All @@ -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
Expand All @@ -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 }}

81 changes: 81 additions & 0 deletions docs/container_registry_migration.md
Original file line number Diff line number Diff line change
@@ -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.

---
Binary file added docs/images/deployment_center.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/resource_menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
15 changes: 13 additions & 2 deletions infra/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
Expand Down Expand Up @@ -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",
Expand Down
Loading