From 024a47a4cf6d38671e653b52092af139c9aeaa65 Mon Sep 17 00:00:00 2001 From: Cassie Breviu <46505951+cassiebreviu@users.noreply.github.com> Date: Wed, 16 Oct 2024 22:11:17 +0000 Subject: [PATCH] update azd to remove postprovision of aca --- azure.yaml | 13 +++++++++++++ infra/hooks/postprovision.ps1 | 22 ---------------------- infra/hooks/postprovision.sh | 16 ---------------- 3 files changed, 13 insertions(+), 38 deletions(-) diff --git a/azure.yaml b/azure.yaml index 1223ebd8..38427e2b 100644 --- a/azure.yaml +++ b/azure.yaml @@ -1,6 +1,19 @@ name: creativeagent metadata: template: creativeagent@0.0.1-beta +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: diff --git a/infra/hooks/postprovision.ps1 b/infra/hooks/postprovision.ps1 index b9916ed2..1f8f3092 100644 --- a/infra/hooks/postprovision.ps1 +++ b/infra/hooks/postprovision.ps1 @@ -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 diff --git a/infra/hooks/postprovision.sh b/infra/hooks/postprovision.sh index f3c81b4b..a93abdee 100755 --- a/infra/hooks/postprovision.sh +++ b/infra/hooks/postprovision.sh @@ -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