-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.azcli
42 lines (30 loc) · 2.17 KB
/
scripts.azcli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
## Create Variables
$RESOURCE_GROUP="rg-demo29"
$LOCATION="northeurope"
$ENVIRONMENT="env-web-xx"
$FRONTEND="frontend"
$BACKEND="backend"
$ACR="xxxxxx"
$IDENTITY="xacridentityx"
## Run Extensions & Provider Registrations
az upgrade
az extension add --name containerapp --upgrade
az provider register --namespace Microsoft.App
az provider register --namespace Microsoft.OperationalInsights
## Create base Resources
az group create --name $RESOURCE_GROUP --location "$LOCATION"
az redis create --location "$LOCATION" --name redis029 --resource-group $RESOURCE_GROUP --sku Basic --vm-size c0 // Add the details to Backend Code!
az acr create --resource-group $RESOURCE_GROUP --name $ACR --sku Basic --admin-enabled true
## Create Container App environment
az containerapp env create --name $ENVIRONMENT -g $RESOURCE_GROUP --location "$LOCATION"
## Build and Deploy Backend Image to Container Registry
az acr build --registry $ACR --image backend .
## Create User Assigned Identity
az identity create --name $IDENTITY --resource-group $RESOURCE_GROUP
$IDENTITY_ID=(az identity show --name $IDENTITY --resource-group $RESOURCE_GROUP --query id)
## Create Container App Backend
az containerapp create --user-assigned $IDENTITY_ID --registry-identity $IDENTITY_ID --name $BACKEND --resource-group $RESOURCE_GROUP --environment $ENVIRONMENT --image "$ACR.azurecr.io/backend:latest" --target-port 5000 --env-vars STORAGE_ACCOUNT_NAME=strkp009 OPENAI_API_KEY=xxxxxxxxxxxxxxxxxxx --ingress 'external' --registry-server "$ACR.azurecr.io" --query properties.configuration.ingress.fqdn
$API_URL=(az containerapp show --resource-group $RESOURCE_GROUP --name $BACKEND --query properties.configuration.ingress.fqdn -o tsv)
## Build and Deploy Frontend Image to Container Registry
az acr build --registry $ACR --image frontend .
az containerapp create --user-assigned $IDENTITY_ID --registry-identity $IDENTITY_ID --name $FRONTEND --resource-group $RESOURCE_GROUP --environment $ENVIRONMENT --image "$ACR.azurecr.io/frontend:latest" --target-port 8000 --env-vars BACKEND_API_URL=https://$API_URL STORAGE_ACCOUNT_NAME=strkp009 --ingress 'external' --registry-server "$ACR.azurecr.io" --query properties.configuration.ingress.fqdn