Skip to content
Open
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
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ AZURE_OPENAI_MAX_TOKENS=2000
# =============================================================================
# Azure Cosmos DB
# =============================================================================
COSMOSDB_ACCOUNT_NAME=your-cosmos-account
AZURE_COSMOS_ENDPOINT=https://your-cosmos.documents.azure.com:443/
AZURE_COSMOS_DATABASE_NAME=content-generation
AZURE_COSMOS_PRODUCTS_CONTAINER=products
Expand Down Expand Up @@ -106,6 +107,7 @@ BRAND_REQUIRED_DISCLOSURES=
# =============================================================================
# Application Settings
# =============================================================================
RESOURCE_GROUP_NAME=your-resource-group
# Server configuration
PORT=5000
WORKERS=4
Expand Down
67 changes: 58 additions & 9 deletions azure_custom.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,35 @@ hooks:
run: |
Write-Host "Preparing deployment..." -ForegroundColor Cyan

# Check if this is first run (ACR doesn't exist yet)
# Set AZURE_ENV_IMAGE_TAG='none' to skip ACI deployment until image is built
if (-not $env:AZURE_ENV_CONTAINER_REGISTRY_NAME) {
# Check if image exists in the ACR (handles fresh deploy AND deployment mode switch)
$acrName = azd env get-value AZURE_ENV_CONTAINER_REGISTRY_NAME 2>$null
$global:LASTEXITCODE = 0
$skipAci = $false

if (-not $acrName) {
Write-Host "First deployment - ACI will be deployed after image build" -ForegroundColor Yellow
$skipAci = $true
} elseif ($acrName -eq 'contentgencontainerreg') {
# Switching from standard (shared ACR) to custom (own ACR) deployment
# Clear ACI name so postprovision deploys fresh with new ACR
Write-Host "Switching to custom deployment - ACI will be redeployed with new ACR" -ForegroundColor Yellow
azd env set CONTAINER_INSTANCE_NAME ""
$skipAci = $true
} else {
# Custom ACR exists - check if image is present
Write-Host "Checking for existing image in $acrName..." -ForegroundColor Cyan
$imageCheck = az acr repository show --name $acrName --image "content-gen-api:latest" 2>$null
$global:LASTEXITCODE = 0

if (-not $imageCheck) {
Write-Host "Image not found in ACR - will build in postprovision" -ForegroundColor Yellow
$skipAci = $true
} else {
Write-Host "Image found - ACI deployment will proceed" -ForegroundColor Green
}
}

if ($skipAci) {
azd env set AZURE_ENV_IMAGE_TAG none
}
continueOnError: false
Expand All @@ -46,9 +71,31 @@ hooks:
run: |
echo "Preparing deployment..."

# Check if this is first run (ACR doesn't exist yet)
if [ -z "$AZURE_ENV_CONTAINER_REGISTRY_NAME" ]; then
# Check if image exists in the ACR (handles fresh deploy AND deployment mode switch)
ACR_NAME=$(azd env get-value AZURE_ENV_CONTAINER_REGISTRY_NAME 2>/dev/null || echo "")
SKIP_ACI=false

if [ -z "$ACR_NAME" ]; then
echo "First deployment - ACI will be deployed after image build"
SKIP_ACI=true
elif [ "$ACR_NAME" = "contentgencontainerreg" ]; then
# Switching from standard (shared ACR) to custom (own ACR) deployment
# Clear ACI name so postprovision deploys fresh with new ACR
echo "Switching to custom deployment - ACI will be redeployed with new ACR"
azd env set CONTAINER_INSTANCE_NAME ""
SKIP_ACI=true
else
# Custom ACR exists - check if image is present
echo "Checking for existing image in $ACR_NAME..."
if az acr repository show --name "$ACR_NAME" --image "content-gen-api:latest" >/dev/null 2>&1; then
echo "Image found - ACI deployment will proceed"
else
echo "Image not found in ACR - will build in postprovision"
SKIP_ACI=true
fi
fi

if [ "$SKIP_ACI" = "true" ]; then
azd env set AZURE_ENV_IMAGE_TAG none
fi
continueOnError: false
Expand Down Expand Up @@ -113,13 +160,13 @@ hooks:
}
} else {
Write-Host ""
Write-Host "Container Instance: $aciName" -ForegroundColor Cyan
Write-Host "Restarting Container Instance to pick up new image..." -ForegroundColor Yellow
az container restart --name $aciName --resource-group $resourceGroup 2>$null
Write-Host "Container Instance: $aciName (restarted)" -ForegroundColor Cyan
}

Write-Host ""
Write-Host "===== Postprovision Complete - Frontend will deploy next =====" -ForegroundColor Green

# Ensure postprovision exits successfully so frontend deploys
exit 0
interactive: true
continueOnError: false
Expand Down Expand Up @@ -178,7 +225,9 @@ hooks:
fi
else
echo ""
echo "Container Instance: $ACI_NAME"
echo "Restarting Container Instance to pick up new image..."
az container restart --name "$ACI_NAME" --resource-group "$RESOURCE_GROUP" 2>/dev/null
echo "Container Instance: $ACI_NAME (restarted)"
fi

echo ""
Expand Down
2 changes: 1 addition & 1 deletion docs/AZD_DEPLOYMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ When `enablePrivateNetworking` is enabled:
└─────────────────────────────────────────────────────────────────┘
```

## Deploy Local Changes
## Advanced: Deploy Local Changes

If you've made local modifications to the code and want to deploy them to Azure, follow these steps to swap the configuration files:

Expand Down
Loading
Loading