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
4 changes: 2 additions & 2 deletions azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/CustomizingAzdParameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | `<Existing Workspace Id>` | Reuses an existing Log Analytics Workspace instead of provisioning a new one. |


Expand Down
25 changes: 13 additions & 12 deletions docs/DeploymentGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ This will allow the scripts to run for the current session without permanently c

<br/>

### **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

Expand Down Expand Up @@ -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)* |


</details>

Expand Down
7 changes: 4 additions & 3 deletions infra/container_app/deploy_container_app_api_web.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -76,7 +77,7 @@ module containerApp 'deploy_container_app.bicep' = {
containerEnvId: containerAppEnvId
azureContainerRegistry: azureContainerRegistry
azureContainerRegistryImage: 'contentprocessor'
azureContainerRegistryImageTag: 'latest'
azureContainerRegistryImageTag: imageTag
managedIdentityId: containerRegistryReaderId
containerEnvVars: [
{
Expand All @@ -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: [
Expand All @@ -123,7 +124,7 @@ module containerAppWeb 'deploy_container_app.bicep' = {
containerEnvId: containerAppEnvId
azureContainerRegistry: azureContainerRegistry
azureContainerRegistryImage: 'contentprocessorweb'
azureContainerRegistryImageTag: 'latest'
azureContainerRegistryImageTag: imageTag
managedIdentityId: containerRegistryReaderId
containerEnvVars: [
{
Expand Down
4 changes: 4 additions & 0 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -176,6 +178,7 @@ module containerApps './container_app/deploy_container_app_api_web.bicep' = {
minReplicaContainerWeb: minReplicaContainerWeb
maxReplicaContainerWeb: maxReplicaContainerWeb
useLocalBuild: 'false'
imageTag: 'latest'
}
}

Expand Down Expand Up @@ -244,6 +247,7 @@ module updateContainerApp './container_app/deploy_container_app_api_web.bicep' =
minReplicaContainerWeb: minReplicaContainerWeb
maxReplicaContainerWeb: maxReplicaContainerWeb
useLocalBuild: useLocalBuildLower
imageTag: imageTag
}
dependsOn: [roleAssignments]
}
Expand Down
1 change: 1 addition & 0 deletions infra/main.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -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', '')
7 changes: 4 additions & 3 deletions infra/scripts/docker-build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ 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
$USE_LOCAL_BUILD = if ($USE_LOCAL_BUILD -match "^(?i:true)$") { $true } else { $false }

# 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 <AZURE_SUBSCRIPTION_ID> <ENV_NAME> <AZURE_LOCATION> <AZURE_RESOURCE_GROUP> <USE_LOCAL_BUILD>"
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>"
exit 1
}

Expand Down Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions infra/scripts/docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <AZURE_SUBSCRIPTION_ID> <ENV_NAME> <AZURE_LOCATION> <AZURE_RESOURCE_GROUP> <USE_LOCAL_BUILD>"
echo "Usage: docker-build.sh <AZURE_SUBSCRIPTION_ID> <ENV_NAME> <AZURE_LOCATION> <AZURE_RESOURCE_GROUP> <USE_LOCAL_BUILD> <AZURE_ENV_IMAGETAG>"
exit 1
fi

Expand All @@ -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")

Expand Down Expand Up @@ -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"
Expand Down
Loading