Skip to content

Commit 6997017

Browse files
Merge pull request #270 from microsoft/image-migration
chore: main branch image migration to internal registry
2 parents e44be19 + baeb7ca commit 6997017

File tree

6 files changed

+120
-11
lines changed

6 files changed

+120
-11
lines changed

.github/workflows/docker-build-and-push.yml

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ jobs:
2424
- name: Set up Docker Buildx
2525
uses: docker/setup-buildx-action@v1
2626

27-
- name: Log in to Azure Container Registry
27+
- name: Log in to Azure Container Registry - External Registry
2828
if: ${{ github.ref_name == 'main' }}
2929
uses: azure/docker-login@v2
3030
with:
3131
login-server: ${{ secrets.ACR_LOGIN_SERVER }}
3232
username: ${{ secrets.ACR_USERNAME }}
3333
password: ${{ secrets.ACR_PASSWORD }}
3434

35-
- name: Log in to Azure Container Registry (Dev/Demo/Dependabotchanges)
36-
if: ${{ github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'dependabotchanges' }}
35+
- name: Log in to Azure Container Registry (Main/Dev/Demo/Dependabotchanges) - Internal Registry
36+
if: ${{ github.ref_name == 'main' ||github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'dependabotchanges' }}
3737
uses: azure/docker-login@v2
3838
with:
3939
login-server: ${{ secrets.ACR_DEV_LOGIN_SERVER }}
@@ -46,7 +46,13 @@ jobs:
4646

4747
- name: Get registry
4848
id: registry
49-
run: echo "registry=${{ github.ref_name == 'main' && secrets.ACR_LOGIN_SERVER || secrets.ACR_DEV_LOGIN_SERVER }}" >> $GITHUB_OUTPUT
49+
run: |
50+
if [[ "${{ github.ref_name }}" == "main" ]]; then
51+
echo "ext_registry=${{ secrets.ACR_LOGIN_SERVER }}" >> $GITHUB_OUTPUT
52+
echo "int_registry=${{ secrets.ACR_DEV_LOGIN_SERVER }}" >> $GITHUB_OUTPUT
53+
else
54+
echo "int_registry=${{ secrets.ACR_DEV_LOGIN_SERVER }}" >> $GITHUB_OUTPUT
55+
fi
5056
5157
- name: Determine Tag Name Based on Branch
5258
id: determine_tag
@@ -61,15 +67,26 @@ jobs:
6167
echo "tagname=dependabotchanges" >> $GITHUB_OUTPUT
6268
else
6369
echo "tagname=default" >> $GITHUB_OUTPUT
64-
6570
fi
6671
67-
- name: Build Docker Image and optionally push
72+
- name: Build Docker Image and optionally push - Internal Registry
6873
uses: docker/build-push-action@v6
6974
with:
7075
context: .
7176
file: WebApp.Dockerfile
7277
push: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'dependabotchanges' }}
7378
tags: |
74-
${{ steps.registry.outputs.registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}
75-
${{ steps.registry.outputs.registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }}
79+
${{ steps.registry.outputs.int_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}
80+
${{ steps.registry.outputs.int_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }}
81+
82+
- name: Build Docker Image and optionally push - External Registry
83+
if: ${{ github.ref_name == 'main' }}
84+
uses: docker/build-push-action@v6
85+
with:
86+
context: .
87+
file: WebApp.Dockerfile
88+
push: ${{github.ref_name == 'main' }}
89+
tags: |
90+
${{ steps.registry.outputs.ext_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}
91+
${{ steps.registry.outputs.ext_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }}
92+
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Guide: Migrating Azure Web App Service to a New Container Registry
2+
3+
## Overview
4+
5+
### Current Problem:
6+
- The **Document Generator Container Image** is being published in the **External ACR** (Azure Container Registry).
7+
8+
### Goal:
9+
- 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.
10+
11+
---
12+
13+
## Step-by-Step Guide: Migrating Azure Web App Service to a New Container Registry
14+
15+
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`**.
16+
17+
Follow the steps below to ensure a smooth migration.
18+
19+
### Prerequisites:
20+
Before you begin, ensure you have the following:
21+
- Access to the **Azure Portal**.
22+
- The **container image** in the new registry is ready and accessible.
23+
24+
---
25+
26+
### Step 1: Obtain Details for the New Registry
27+
28+
Before you begin, ensure you have the following information:
29+
- **Registry URL**: The URL of the new registry (`https://byocgacontainerreg.azurecr.io`).
30+
- **Image Name and Tag**: The full name and tag of the image you want to use:
31+
- **Web App Image**: `webapp:latest`
32+
---
33+
34+
### Step 2: Update Azure Web App Service Configuration Using Azure Portal
35+
36+
1. **Log in to Azure Portal**:
37+
- Open [Azure Portal](https://portal.azure.com/).
38+
39+
2. **Locate Your Resource Group and Web App Service**:
40+
- Navigate to resource group which you have created for Document Generator.
41+
- Navigate to **Web App Service**: From the list of resources, find and select **App Service**
42+
43+
3. **Go to the Deployment Center**:
44+
- In the left-hand menu, click on **Deployment**.
45+
46+
![Resource Menu](images/resource_menu.png)
47+
48+
49+
4. **Update Image Source**:
50+
- Change the **Registry Source** to **Private**.
51+
- Set the **Server URL** to the new container registry (`https://byocgacontainerreg.azurecr.io`), as shown in the screenshot below.
52+
- Set the **Full Image name** to the relevant image name and tag:
53+
- For Web App: `webapp:latest`
54+
55+
![Deployment Center](images/deployment_center.png)
56+
57+
5. **Save Changes**:
58+
- Click **Save** to save the configuration.
59+
60+
---
61+
62+
### Step 3: Restart the Web App Service
63+
64+
After updating the configuration, restart your **Web App Service** to apply the changes:
65+
66+
1. In the **Web App Service overview page**, click on **Restart**.
67+
2. Confirm the restart operation.
68+
69+
---
70+
71+
### Step 8: Validate the Deployment
72+
73+
1. **Access Your Web App**:
74+
- Open the **Web App URL** in a browser to ensure it’s running correctly.
75+
---
76+
77+
By following these steps, your **Azure Web App Service** will now use the new container from the **Document Generator registry**.
78+
79+
For further assistance, feel free to reach out to your support team or log an issue on GitHub.
80+
81+
---

docs/images/deployment_center.png

109 KB
Loading

docs/images/resource_menu.png

107 KB
Loading

infra/main.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ param AzureOpenAIStopSequence string = '\n'
166166
@description('Whether or not to stream responses from Azure OpenAI? True or False.')
167167
param AzureOpenAIStream bool = true
168168

169-
var WebAppImageName = 'DOCKER|acrbyocga.azurecr.io/webapp:latest'
169+
var WebAppImageName = 'DOCKER|byocgacontainerreg.azurecr.io/webapp:latest'
170170
var cosmosdb_database_name = 'db_conversation_history'
171171
var cosmosdb_container_name = 'conversations'
172172
var roleDefinitionId = '00000000-0000-0000-0000-000000000002'

infra/main.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,25 @@
55
"_generator": {
66
"name": "bicep",
77
"version": "0.33.93.31351",
8-
"templateHash": "896617532796464630"
8+
"templateHash": "7005910716688710298"
99
}
1010
},
1111
"parameters": {
12+
"environmentName": {
13+
"type": "string",
14+
"minLength": 3,
15+
"maxLength": 10,
16+
"metadata": {
17+
"description": "A unique prefix for all resources in this deployment. This should be 3-10 characters long:"
18+
}
19+
},
1220
"HostingPlanName": {
1321
"type": "string",
1422
"defaultValue": "[guid(resourceGroup().id)]",
1523
"metadata": {
24+
"azd": {
25+
"type": "location"
26+
},
1627
"description": "Name of App Service plan"
1728
}
1829
},
@@ -263,7 +274,7 @@
263274
}
264275
},
265276
"variables": {
266-
"WebAppImageName": "DOCKER|acrbyocga.azurecr.io/webapp:latest",
277+
"WebAppImageName": "DOCKER|byocgacontainerreg.azurecr.io/webapp:latest",
267278
"cosmosdb_database_name": "db_conversation_history",
268279
"cosmosdb_container_name": "conversations",
269280
"roleDefinitionId": "00000000-0000-0000-0000-000000000002",

0 commit comments

Comments
 (0)