Skip to content

Commit

Permalink
Setup session affinity for azure
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaranvpl committed Nov 29, 2024
1 parent 6f68344 commit d8cb381
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions {{cookiecutter.project_slug}}/scripts/deploy_to_azure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"
Expand All @@ -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"

0 comments on commit d8cb381

Please sign in to comment.