From d8cb38190edf2214086d782d54ae720bcf49fa12 Mon Sep 17 00:00:00 2001 From: Kumaran Rajendhiran Date: Fri, 29 Nov 2024 13:42:48 +0530 Subject: [PATCH] Setup session affinity for azure --- .../scripts/deploy_to_azure.sh | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/{{cookiecutter.project_slug}}/scripts/deploy_to_azure.sh b/{{cookiecutter.project_slug}}/scripts/deploy_to_azure.sh index 3ddc61a..6da751c 100755 --- a/{{cookiecutter.project_slug}}/scripts/deploy_to_azure.sh +++ b/{{cookiecutter.project_slug}}/scripts/deploy_to_azure.sh @@ -17,10 +17,6 @@ else echo -e "\033[0;32mAlready logged into Azure\033[0m" fi -# az extension add --name containerapp --upgrade -# az provider register --namespace Microsoft.App -# az provider register --namespace Microsoft.OperationalInsights - echo -e "\033[0;32mCreating resource group if it doesn't exists already\033[0m" az group create --name $RESOURCE_GROUP --location $LOCATION @@ -54,10 +50,10 @@ az containerapp create \ --ingress 'external' \ --query properties.configuration.ingress.fqdn \ --registry-server $ACR_NAME.azurecr.io \ - --cpu 0.5 \ - --memory 1Gi \ + --cpu 1 \ + --memory 2Gi \ --min-replicas 0 \ - --max-replicas 1 \ + --max-replicas 2 \ --env-vars OPENAI_API_KEY=$OPENAI_API_KEY {% if "nats" in cookiecutter.app_type %} # echo -e "\033[0;32mUpdating nats port in container app\033[0m" @@ -75,3 +71,13 @@ az containerapp create \ # --name $CONTAINER_APP_NAME \ # --resource-group $RESOURCE_GROUP \ # --add-ports 8888{%- endif %} + +echo -e "\033[0;32mSetting up session affinity\033[0m" +az containerapp ingress sticky-sessions set \ + --name $CONTAINER_APP_NAME \ + --resource-group $RESOURCE_GROUP \ + --affinity sticky + +echo -e "\033[0;32mFetching your Azure Container App's hosted URL\033[0m" +FQDN=$(az containerapp show --name $CONTAINER_APP_NAME --resource-group $RESOURCE_GROUP --query properties.configuration.ingress.fqdn -o tsv) +echo -e "\033[0;32mYour Azure Container App's hosted URL is: https://$FQDN\033[0m"