Skip to content

Commit

Permalink
update azd to remove postprovision of aca (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
cassiebreviu authored Oct 16, 2024
1 parent 29337b6 commit 2a98d56
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 38 deletions.
13 changes: 13 additions & 0 deletions azure.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
name: creativeagent
metadata:
template: [email protected]
services:
api:
project: ./src/api
language: python
host: containerapp
docker:
remoteBuild: true
web:
project: ./src/web
language: js
host: containerapp
docker:
remoteBuild: true
hooks:
postprovision:
posix:
Expand Down
22 changes: 0 additions & 22 deletions infra/hooks/postprovision.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,6 @@ $ErrorActionPreference = 'Stop'
Write-Output "Outputting environment variables to .env file..."
azd env get-values > .env

function acr_build {
param (
[string]$image_name,
[string]$aca_name,
[string]$src_dir,
[int]$target_port
)

$image_fqn = "$env:AZURE_CONTAINER_REGISTRY_NAME.azurecr.io/$image_name"
Write-Output "Building $image_name using $src_dir ..."
az acr build --subscription $env:AZURE_SUBSCRIPTION_ID --registry $env:AZURE_CONTAINER_REGISTRY_NAME --image $image_name $src_dir
az containerapp update --subscription $env:AZURE_SUBSCRIPTION_ID --name $aca_name --resource-group $env:AZURE_RESOURCE_GROUP --image $image_fqn
az containerapp ingress update --subscription $env:AZURE_SUBSCRIPTION_ID --name $aca_name --resource-group $env:AZURE_RESOURCE_GROUP --target-port $target_port
}

# Generate a tag with current date and time
$TAG = (Get-Date).ToString("yyyyMMdd-HHmmss")

# Build images and update container apps
acr_build "creativeagentapi:$TAG" $env:API_SERVICE_ACA_NAME "./src/api/" 80
acr_build "creativeagentweb:$TAG" $env:WEB_SERVICE_ACA_NAME "./src/web/" 80

# Retrieve service names, resource group name, and other values from environment variables
$resourceGroupName = $env:AZURE_RESOURCE_GROUP
$searchService = $env:AZURE_SEARCH_NAME
Expand Down
16 changes: 0 additions & 16 deletions infra/hooks/postprovision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,6 @@ set -e
# Output environment variables to .env file using azd env get-values
azd env get-values > .env

acr_build () {
image_name=$1
aca_name=$2
src_dir=$3
target_port=$4
image_fqn="${AZURE_CONTAINER_REGISTRY_NAME}.azurecr.io/${image_name}"
echo "Building ${image_name} using ${src_dir} ..."
az acr build --subscription ${AZURE_SUBSCRIPTION_ID} --registry ${AZURE_CONTAINER_REGISTRY_NAME} --image ${image_name} ${src_dir}
az containerapp update --subscription ${AZURE_SUBSCRIPTION_ID} --name ${aca_name} --resource-group ${AZURE_RESOURCE_GROUP} --image ${image_fqn}
az containerapp ingress update --subscription ${AZURE_SUBSCRIPTION_ID} --name ${aca_name} --resource-group ${AZURE_RESOURCE_GROUP} --target-port ${target_port}
}

TAG=$(date +%Y%m%d-%H%M%S)
acr_build creativeagentapi:${TAG} ${API_SERVICE_ACA_NAME} ./src/api/ 80
acr_build creativeagentweb:${TAG} ${WEB_SERVICE_ACA_NAME} ./src/web/ 80

# Retrieve service names, resource group name, and other values from environment variables
resourceGroupName=$AZURE_RESOURCE_GROUP
searchService=$AZURE_SEARCH_NAME
Expand Down

0 comments on commit 2a98d56

Please sign in to comment.