Skip to content

Commit 664c285

Browse files
Merge pull request #180 from microsoft/psl-imagetag-changes
feat: added image tag related changes.
2 parents 4c98065 + 7584597 commit 664c285

8 files changed

Lines changed: 35 additions & 24 deletions

File tree

azure.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ hooks:
1111
preprovision:
1212
posix:
1313
shell: sh
14-
run: timestamp=$(date +"%Y%m%d-%H%M%S"); logFile="azd_preprovision_$timestamp.log"; sed -i 's/\r$//' ./infra/scripts/docker-build.sh; ./infra/scripts/docker-build.sh "$AZURE_SUBSCRIPTION_ID" "$AZURE_ENV_NAME" "$AZURE_LOCATION" "$AZURE_RESOURCE_GROUP" "$USE_LOCAL_BUILD" 2>&1 | tee "$logFile"
14+
run: timestamp=$(date +"%Y%m%d-%H%M%S"); logFile="azd_preprovision_$timestamp.log"; sed -i 's/\r$//' ./infra/scripts/docker-build.sh; ./infra/scripts/docker-build.sh "$AZURE_SUBSCRIPTION_ID" "$AZURE_ENV_NAME" "$AZURE_LOCATION" "$AZURE_RESOURCE_GROUP" "$USE_LOCAL_BUILD" "$AZURE_ENV_IMAGETAG" 2>&1 | tee "$logFile"
1515
windows:
1616
shell: pwsh
17-
run: $timestamp = Get-Date -Format "yyyyMMdd-HHmmss"; $logFile = "azd_preprovision_$timestamp.log"; ./infra/scripts/docker-build.ps1 $env:AZURE_SUBSCRIPTION_ID $env:AZURE_ENV_NAME $env:AZURE_LOCATION $env:AZURE_RESOURCE_GROUP $env:USE_LOCAL_BUILD *>&1 | Tee-Object -FilePath $logFile
17+
run: $timestamp = Get-Date -Format "yyyyMMdd-HHmmss"; $logFile = "azd_preprovision_$timestamp.log"; ./infra/scripts/docker-build.ps1 $env:AZURE_SUBSCRIPTION_ID $env:AZURE_ENV_NAME $env:AZURE_LOCATION $env:AZURE_RESOURCE_GROUP $env:USE_LOCAL_BUILD $env:AZURE_ENV_IMAGETAG *>&1 | Tee-Object -FilePath $logFile
1818
postprovision:
1919
posix:
2020
shell: sh

docs/CustomizingAzdParameters.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ By default this template will use the environment name as the prefix to prevent
1717
| `AZURE_ENV_MODEL_VERSION` | string | `2024-08-06` | Specifies the GPT model version (allowed values: `2024-08-06`). |
1818
| `AZURE_ENV_MODEL_CAPACITY` | integer | `30` | Sets the model capacity (choose based on your subscription's available GPT capacity). |
1919
| `USE_LOCAL_BUILD` | boolean | `false` | Indicates whether to use a local container build for deployment. |
20+
| `AZURE_ENV_IMAGETAG` | boolean | `latest` | Set the Image tag Like (allowed values: latest, dev, hotfix) |
2021
| `AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID` | string | `<Existing Workspace Id>` | Reuses an existing Log Analytics Workspace instead of provisioning a new one. |
2122

2223

docs/DeploymentGuide.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ This will allow the scripts to run for the current session without permanently c
3636

3737
<br/>
3838

39-
### **Configurable Deployment Settings**
40-
41-
When you start the deployment, most parameters will have **default values**, but you can update the following settings by following the steps [here](../docs/CustomizingAzdParameters.md):
4239

4340
## Deployment Options & Steps
4441

@@ -115,15 +112,19 @@ Consider the following settings during your deployment to modify specific settin
115112

116113
When you start the deployment, most parameters will have **default values**, but you can update the following settings by following the steps [here](../docs/CustomizingAzdParameters.md):
117114

118-
| **Setting** | **Description** | **Default value** |
119-
|-------------|-----------------|-------------------|
120-
| **Azure Region** | The region where resources will be created. | East US |
121-
| **Azure AI Content Understanding Location** | Select from a drop-down list of values. | Sweden Central |
122-
| **Secondary Location** | A **less busy** region for **Azure Cosmos DB**, useful in case of availability constraints. | eastus2 |
123-
| **Deployment Type** | Select from a drop-down list. | GlobalStandard |
124-
| **GPT Model** | Choose from **gpt-4o**. | gpt-4o |
125-
| **GPT Model Deployment Capacity** | Configure capacity for **GPT models**. | 30k |
126-
| **Existing Log analytics workspace** | To reuse the existing Log analytics workspace Id. | |
115+
| **Setting** | **Description** | **Default Value** |
116+
| ------------------------------------------- | ------------------------------------------------------------------------------------------- | ----------------- |
117+
| **Azure Region** | The region where resources will be created. | East US |
118+
| **Azure AI Content Understanding Location** | Location for the **Content Understanding** service. | Sweden Central |
119+
| **Secondary Location** | A **less busy** region for **Azure Cosmos DB**, useful in case of availability constraints. | eastus2 |
120+
| **Deployment Type** | Select from a drop-down list. | GlobalStandard |
121+
| **GPT Model** | Choose from **gpt-4o**. | gpt-4o |
122+
| **GPT Model Version** | GPT model version used in the deployment. | 2024-08-06 |
123+
| **GPT Model Deployment Capacity** | Configure capacity for **GPT models**. | 30k |
124+
| **Use Local Build** | Boolean flag to determine if local container builds should be used. | false |
125+
| **Image Tag** | Image version for deployment (allowed values: `latest`, `dev`, `hotfix`). | latest |
126+
| **Existing Log Analytics Workspace** | To reuse an existing Log Analytics Workspace ID instead of creating a new one. | *(none)* |
127+
127128

128129
</details>
129130

infra/container_app/deploy_container_app_api_web.bicep

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ param maxReplicaContainerWeb int = 1
2626
param azureContainerRegistry string
2727
param containerRegistryReaderId string
2828
param useLocalBuild string = 'false'
29+
param imageTag string
2930

3031
var abbrs = loadJsonContent('../abbreviations.json')
3132

@@ -76,7 +77,7 @@ module containerApp 'deploy_container_app.bicep' = {
7677
containerEnvId: containerAppEnvId
7778
azureContainerRegistry: azureContainerRegistry
7879
azureContainerRegistryImage: 'contentprocessor'
79-
azureContainerRegistryImageTag: 'latest'
80+
azureContainerRegistryImageTag: imageTag
8081
managedIdentityId: containerRegistryReaderId
8182
containerEnvVars: [
8283
{
@@ -99,7 +100,7 @@ module containerAppApi 'deploy_container_app.bicep' = {
99100
containerEnvId: containerAppEnvId
100101
azureContainerRegistry: azureContainerRegistry
101102
azureContainerRegistryImage: 'contentprocessorapi'
102-
azureContainerRegistryImageTag: 'latest'
103+
azureContainerRegistryImageTag: imageTag
103104
managedIdentityId: containerRegistryReaderId
104105
allowedOrigins: [containerAppWebEndpoint]
105106
containerEnvVars: [
@@ -123,7 +124,7 @@ module containerAppWeb 'deploy_container_app.bicep' = {
123124
containerEnvId: containerAppEnvId
124125
azureContainerRegistry: azureContainerRegistry
125126
azureContainerRegistryImage: 'contentprocessorweb'
126-
azureContainerRegistryImageTag: 'latest'
127+
azureContainerRegistryImageTag: imageTag
127128
managedIdentityId: containerRegistryReaderId
128129
containerEnvVars: [
129130
{

infra/main.bicep

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ param useLocalBuild string = 'false'
6868
@description('Optional: Existing Log Analytics Workspace Resource ID')
6969
param existingLogAnalyticsWorkspaceId string = ''
7070

71+
param imageTag string = 'latest'
72+
7173
var containerImageEndPoint = 'cpscontainerreg.azurecr.io'
7274
var resourceGroupLocation = resourceGroup().location
7375

@@ -176,6 +178,7 @@ module containerApps './container_app/deploy_container_app_api_web.bicep' = {
176178
minReplicaContainerWeb: minReplicaContainerWeb
177179
maxReplicaContainerWeb: maxReplicaContainerWeb
178180
useLocalBuild: 'false'
181+
imageTag: 'latest'
179182
}
180183
}
181184

@@ -244,6 +247,7 @@ module updateContainerApp './container_app/deploy_container_app_api_web.bicep' =
244247
minReplicaContainerWeb: minReplicaContainerWeb
245248
maxReplicaContainerWeb: maxReplicaContainerWeb
246249
useLocalBuild: useLocalBuildLower
250+
imageTag: imageTag
247251
}
248252
dependsOn: [roleAssignments]
249253
}

infra/main.bicepparam

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ param gptModelName = readEnvironmentVariable('AZURE_ENV_MODEL_NAME', 'gpt-4o')
88
param gptModelVersion = readEnvironmentVariable('AZURE_ENV_MODEL_VERSION', '2024-08-06')
99
param gptDeploymentCapacity = int(readEnvironmentVariable('AZURE_ENV_MODEL_CAPACITY', '30'))
1010
param useLocalBuild = readEnvironmentVariable('USE_LOCAL_BUILD', 'false')
11+
param imageTag = readEnvironmentVariable('AZURE_ENV_IMAGETAG', 'latest')
1112
param existingLogAnalyticsWorkspaceId = readEnvironmentVariable('AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID', '')

infra/scripts/docker-build.ps1

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ param (
44
[string]$ENV_NAME,
55
[string]$AZURE_LOCATION,
66
[string]$AZURE_RESOURCE_GROUP,
7-
[string]$USE_LOCAL_BUILD
7+
[string]$USE_LOCAL_BUILD,
8+
[string]$AZURE_ENV_IMAGETAG
89
)
910

1011
# Convert USE_LOCAL_BUILD to Boolean
1112
$USE_LOCAL_BUILD = if ($USE_LOCAL_BUILD -match "^(?i:true)$") { $true } else { $false }
1213

1314
# Validate required parameters
1415
if (-not $AZURE_SUBSCRIPTION_ID -or -not $ENV_NAME -or -not $AZURE_LOCATION -or -not $AZURE_RESOURCE_GROUP) {
15-
Write-Error "Missing required arguments. Usage: docker-build.ps1 <AZURE_SUBSCRIPTION_ID> <ENV_NAME> <AZURE_LOCATION> <AZURE_RESOURCE_GROUP> <USE_LOCAL_BUILD>"
16+
Write-Error "Missing required arguments. Usage: docker-build.ps1 <AZURE_SUBSCRIPTION_ID> <ENV_NAME> <AZURE_LOCATION> <AZURE_RESOURCE_GROUP> <USE_LOCAL_BUILD> <AZURE_ENV_IMAGETAG>"
1617
exit 1
1718
}
1819

@@ -57,7 +58,7 @@ function Build-And-Push-Image {
5758
[string]$BUILD_PATH
5859
)
5960

60-
$IMAGE_URI = "$ACR_NAME.azurecr.io/$($IMAGE_NAME):latest"
61+
$IMAGE_URI = "$ACR_NAME.azurecr.io/$($IMAGE_NAME):$AZURE_ENV_IMAGETAG"
6162

6263
Write-Host "Building Docker image: $IMAGE_URI"
6364
docker build $BUILD_PATH --no-cache -t $IMAGE_URI

infra/scripts/docker-build.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ echo $2
77
echo $3
88
echo $4
99
echo $5
10+
echo $6
1011

1112
# Check if the required arguments are provided
1213
if [ "$#" -ne 5 ]; then
13-
echo "Usage: docker-build.sh <AZURE_SUBSCRIPTION_ID> <ENV_NAME> <AZURE_LOCATION> <AZURE_RESOURCE_GROUP> <USE_LOCAL_BUILD>"
14+
echo "Usage: docker-build.sh <AZURE_SUBSCRIPTION_ID> <ENV_NAME> <AZURE_LOCATION> <AZURE_RESOURCE_GROUP> <USE_LOCAL_BUILD> <AZURE_ENV_IMAGETAG>"
1415
exit 1
1516
fi
1617

@@ -19,6 +20,7 @@ ENV_NAME=$2
1920
AZURE_LOCATION=$3
2021
AZURE_RESOURCE_GROUP=$4
2122
USE_LOCAL_BUILD=$5
23+
AZURE_ENV_IMAGETAG=$6
2224

2325
USE_LOCAL_BUILD=$(echo "$USE_LOCAL_BUILD" | grep -iq "^true$" && echo "true" || echo "false")
2426

@@ -49,9 +51,9 @@ if [ "$USE_LOCAL_BUILD" = "true" ]; then
4951
echo "Deployed container registry in location."
5052

5153
# Construct full image names
52-
CONTENTPROCESSOR_IMAGE_URI="$ACR_NAME.azurecr.io/contentprocessor:latest"
53-
CONTENTPROCESSORAPI_IMAGE_URI="$ACR_NAME.azurecr.io/contentprocessorapi:latest"
54-
CONTENTPROCESSORWEB_IMAGE_URI="$ACR_NAME.azurecr.io/contentprocessorweb:latest"
54+
CONTENTPROCESSOR_IMAGE_URI="$ACR_NAME.azurecr.io/contentprocessor:$AZURE_ENV_IMAGETAG"
55+
CONTENTPROCESSORAPI_IMAGE_URI="$ACR_NAME.azurecr.io/contentprocessorapi:$AZURE_ENV_IMAGETAG"
56+
CONTENTPROCESSORWEB_IMAGE_URI="$ACR_NAME.azurecr.io/contentprocessorweb:$AZURE_ENV_IMAGETAG"
5557

5658
# Azure login
5759
echo "Logging into Azure Container Registry: $ACR_NAME"

0 commit comments

Comments
 (0)