Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update azd to remove postprovision of aca #229

Merged
merged 1 commit into from
Oct 16, 2024
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
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
Loading