diff --git a/azure.yaml b/azure.yaml index bf46bfb5..b5b9121e 100644 --- a/azure.yaml +++ b/azure.yaml @@ -11,10 +11,10 @@ hooks: preprovision: posix: shell: sh - 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" + 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" windows: shell: pwsh - 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 + 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 postprovision: posix: shell: sh diff --git a/docs/CustomizingAzdParameters.md b/docs/CustomizingAzdParameters.md index aad59007..0402503e 100644 --- a/docs/CustomizingAzdParameters.md +++ b/docs/CustomizingAzdParameters.md @@ -17,6 +17,7 @@ By default this template will use the environment name as the prefix to prevent | `AZURE_ENV_MODEL_VERSION` | string | `2024-08-06` | Specifies the GPT model version (allowed values: `2024-08-06`). | | `AZURE_ENV_MODEL_CAPACITY` | integer | `30` | Sets the model capacity (choose based on your subscription's available GPT capacity). | | `USE_LOCAL_BUILD` | boolean | `false` | Indicates whether to use a local container build for deployment. | +| `AZURE_ENV_IMAGETAG` | boolean | `latest` | Set the Image tag Like (allowed values: latest, dev, hotfix) | | `AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID` | string | `` | Reuses an existing Log Analytics Workspace instead of provisioning a new one. | diff --git a/docs/DeploymentGuide.md b/docs/DeploymentGuide.md index 4b3d8173..0735575f 100644 --- a/docs/DeploymentGuide.md +++ b/docs/DeploymentGuide.md @@ -36,9 +36,6 @@ This will allow the scripts to run for the current session without permanently c
-### **Configurable Deployment Settings** - -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): ## Deployment Options & Steps @@ -115,15 +112,19 @@ Consider the following settings during your deployment to modify specific settin 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): -| **Setting** | **Description** | **Default value** | -|-------------|-----------------|-------------------| -| **Azure Region** | The region where resources will be created. | East US | -| **Azure AI Content Understanding Location** | Select from a drop-down list of values. | Sweden Central | -| **Secondary Location** | A **less busy** region for **Azure Cosmos DB**, useful in case of availability constraints. | eastus2 | -| **Deployment Type** | Select from a drop-down list. | GlobalStandard | -| **GPT Model** | Choose from **gpt-4o**. | gpt-4o | -| **GPT Model Deployment Capacity** | Configure capacity for **GPT models**. | 30k | -| **Existing Log analytics workspace** | To reuse the existing Log analytics workspace Id. | | +| **Setting** | **Description** | **Default Value** | +| ------------------------------------------- | ------------------------------------------------------------------------------------------- | ----------------- | +| **Azure Region** | The region where resources will be created. | East US | +| **Azure AI Content Understanding Location** | Location for the **Content Understanding** service. | Sweden Central | +| **Secondary Location** | A **less busy** region for **Azure Cosmos DB**, useful in case of availability constraints. | eastus2 | +| **Deployment Type** | Select from a drop-down list. | GlobalStandard | +| **GPT Model** | Choose from **gpt-4o**. | gpt-4o | +| **GPT Model Version** | GPT model version used in the deployment. | 2024-08-06 | +| **GPT Model Deployment Capacity** | Configure capacity for **GPT models**. | 30k | +| **Use Local Build** | Boolean flag to determine if local container builds should be used. | false | +| **Image Tag** | Image version for deployment (allowed values: `latest`, `dev`, `hotfix`). | latest | +| **Existing Log Analytics Workspace** | To reuse an existing Log Analytics Workspace ID instead of creating a new one. | *(none)* | + diff --git a/infra/container_app/deploy_container_app_api_web.bicep b/infra/container_app/deploy_container_app_api_web.bicep index 9c4c23de..41272dd2 100644 --- a/infra/container_app/deploy_container_app_api_web.bicep +++ b/infra/container_app/deploy_container_app_api_web.bicep @@ -26,6 +26,7 @@ param maxReplicaContainerWeb int = 1 param azureContainerRegistry string param containerRegistryReaderId string param useLocalBuild string = 'false' +param imageTag string var abbrs = loadJsonContent('../abbreviations.json') @@ -76,7 +77,7 @@ module containerApp 'deploy_container_app.bicep' = { containerEnvId: containerAppEnvId azureContainerRegistry: azureContainerRegistry azureContainerRegistryImage: 'contentprocessor' - azureContainerRegistryImageTag: 'latest' + azureContainerRegistryImageTag: imageTag managedIdentityId: containerRegistryReaderId containerEnvVars: [ { @@ -99,7 +100,7 @@ module containerAppApi 'deploy_container_app.bicep' = { containerEnvId: containerAppEnvId azureContainerRegistry: azureContainerRegistry azureContainerRegistryImage: 'contentprocessorapi' - azureContainerRegistryImageTag: 'latest' + azureContainerRegistryImageTag: imageTag managedIdentityId: containerRegistryReaderId allowedOrigins: [containerAppWebEndpoint] containerEnvVars: [ @@ -123,7 +124,7 @@ module containerAppWeb 'deploy_container_app.bicep' = { containerEnvId: containerAppEnvId azureContainerRegistry: azureContainerRegistry azureContainerRegistryImage: 'contentprocessorweb' - azureContainerRegistryImageTag: 'latest' + azureContainerRegistryImageTag: imageTag managedIdentityId: containerRegistryReaderId containerEnvVars: [ { diff --git a/infra/main.bicep b/infra/main.bicep index 76dc12de..99a5b016 100644 --- a/infra/main.bicep +++ b/infra/main.bicep @@ -68,6 +68,8 @@ param useLocalBuild string = 'false' @description('Optional: Existing Log Analytics Workspace Resource ID') param existingLogAnalyticsWorkspaceId string = '' +param imageTag string = 'latest' + var containerImageEndPoint = 'cpscontainerreg.azurecr.io' var resourceGroupLocation = resourceGroup().location @@ -176,6 +178,7 @@ module containerApps './container_app/deploy_container_app_api_web.bicep' = { minReplicaContainerWeb: minReplicaContainerWeb maxReplicaContainerWeb: maxReplicaContainerWeb useLocalBuild: 'false' + imageTag: 'latest' } } @@ -244,6 +247,7 @@ module updateContainerApp './container_app/deploy_container_app_api_web.bicep' = minReplicaContainerWeb: minReplicaContainerWeb maxReplicaContainerWeb: maxReplicaContainerWeb useLocalBuild: useLocalBuildLower + imageTag: imageTag } dependsOn: [roleAssignments] } diff --git a/infra/main.bicepparam b/infra/main.bicepparam index c7b1515b..b6a15d71 100644 --- a/infra/main.bicepparam +++ b/infra/main.bicepparam @@ -8,4 +8,5 @@ param gptModelName = readEnvironmentVariable('AZURE_ENV_MODEL_NAME', 'gpt-4o') param gptModelVersion = readEnvironmentVariable('AZURE_ENV_MODEL_VERSION', '2024-08-06') param gptDeploymentCapacity = int(readEnvironmentVariable('AZURE_ENV_MODEL_CAPACITY', '30')) param useLocalBuild = readEnvironmentVariable('USE_LOCAL_BUILD', 'false') +param imageTag = readEnvironmentVariable('AZURE_ENV_IMAGETAG', 'latest') param existingLogAnalyticsWorkspaceId = readEnvironmentVariable('AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID', '') diff --git a/infra/scripts/docker-build.ps1 b/infra/scripts/docker-build.ps1 index 9c998810..10b5632a 100644 --- a/infra/scripts/docker-build.ps1 +++ b/infra/scripts/docker-build.ps1 @@ -4,7 +4,8 @@ param ( [string]$ENV_NAME, [string]$AZURE_LOCATION, [string]$AZURE_RESOURCE_GROUP, - [string]$USE_LOCAL_BUILD + [string]$USE_LOCAL_BUILD, + [string]$AZURE_ENV_IMAGETAG ) # Convert USE_LOCAL_BUILD to Boolean @@ -12,7 +13,7 @@ $USE_LOCAL_BUILD = if ($USE_LOCAL_BUILD -match "^(?i:true)$") { $true } else { $ # Validate required parameters if (-not $AZURE_SUBSCRIPTION_ID -or -not $ENV_NAME -or -not $AZURE_LOCATION -or -not $AZURE_RESOURCE_GROUP) { - Write-Error "Missing required arguments. Usage: docker-build.ps1 " + Write-Error "Missing required arguments. Usage: docker-build.ps1 " exit 1 } @@ -57,7 +58,7 @@ function Build-And-Push-Image { [string]$BUILD_PATH ) - $IMAGE_URI = "$ACR_NAME.azurecr.io/$($IMAGE_NAME):latest" + $IMAGE_URI = "$ACR_NAME.azurecr.io/$($IMAGE_NAME):$AZURE_ENV_IMAGETAG" Write-Host "Building Docker image: $IMAGE_URI" docker build $BUILD_PATH --no-cache -t $IMAGE_URI diff --git a/infra/scripts/docker-build.sh b/infra/scripts/docker-build.sh index ddb22b2f..d1833938 100644 --- a/infra/scripts/docker-build.sh +++ b/infra/scripts/docker-build.sh @@ -7,10 +7,11 @@ echo $2 echo $3 echo $4 echo $5 +echo $6 # Check if the required arguments are provided if [ "$#" -ne 5 ]; then - echo "Usage: docker-build.sh " + echo "Usage: docker-build.sh " exit 1 fi @@ -19,6 +20,7 @@ ENV_NAME=$2 AZURE_LOCATION=$3 AZURE_RESOURCE_GROUP=$4 USE_LOCAL_BUILD=$5 +AZURE_ENV_IMAGETAG=$6 USE_LOCAL_BUILD=$(echo "$USE_LOCAL_BUILD" | grep -iq "^true$" && echo "true" || echo "false") @@ -49,9 +51,9 @@ if [ "$USE_LOCAL_BUILD" = "true" ]; then echo "Deployed container registry in location." # Construct full image names - CONTENTPROCESSOR_IMAGE_URI="$ACR_NAME.azurecr.io/contentprocessor:latest" - CONTENTPROCESSORAPI_IMAGE_URI="$ACR_NAME.azurecr.io/contentprocessorapi:latest" - CONTENTPROCESSORWEB_IMAGE_URI="$ACR_NAME.azurecr.io/contentprocessorweb:latest" + CONTENTPROCESSOR_IMAGE_URI="$ACR_NAME.azurecr.io/contentprocessor:$AZURE_ENV_IMAGETAG" + CONTENTPROCESSORAPI_IMAGE_URI="$ACR_NAME.azurecr.io/contentprocessorapi:$AZURE_ENV_IMAGETAG" + CONTENTPROCESSORWEB_IMAGE_URI="$ACR_NAME.azurecr.io/contentprocessorweb:$AZURE_ENV_IMAGETAG" # Azure login echo "Logging into Azure Container Registry: $ACR_NAME"