Skip to content

Commit 91afc98

Browse files
committed
aks deployment review. documentation update
1 parent 703290b commit 91afc98

11 files changed

Lines changed: 279 additions & 86 deletions

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,9 @@ static/
154154
app/backend/manifests/azd-env-configmap.yml
155155
deploy/aks/easyauth/config-output.md
156156
deploy/aks/easyauth/easyauth-ingress.yaml
157+
158+
# Keys and certificates
159+
*.pem
160+
*.key
161+
*.crt
162+
*.pfx

deploy/aks/ingress-tls.yml

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
apiVersion: networking.k8s.io/v1
2-
kind: Ingress
3-
metadata:
4-
name: ingress-api
5-
namespace: java-rag-ns
6-
annotations:
7-
nginx.ingress.kubernetes.io/proxy-body-size : "20m"
8-
kubernetes.azure.com/tls-cert-keyvault-uri: https://kv-dwnlxp47m7pwq.vault.azure.net/certificates/aks-ingress-tls
9-
spec:
10-
ingressClassName: webapprouting.kubernetes.azure.com
11-
rules:
12-
- host: java-rag-aks-test3.eastus2.cloudapp.azure.com
13-
http:
14-
paths:
15-
- path: /api
16-
pathType: Prefix
17-
backend:
18-
service:
19-
name: backend-service
20-
port:
21-
number: 80
22-
- path: /
23-
pathType: Prefix
24-
backend:
25-
service:
26-
name: frontend-service
27-
port:
28-
number: 80
29-
tls:
30-
- hosts:
31-
- java-rag-aks-test3.eastus2.cloudapp.azure.com
32-
secretName: keyvault-ingress-api
1+
apiVersion: networking.k8s.io/v1
2+
kind: Ingress
3+
metadata:
4+
name: ingress-api
5+
namespace: java-rag-ns
6+
annotations:
7+
nginx.ingress.kubernetes.io/proxy-body-size : "20m"
8+
kubernetes.azure.com/tls-cert-keyvault-uri: https://kv-7nfq3jzs3kbrs.vault.azure.net/certificates/aks-ingress-tls
9+
spec:
10+
ingressClassName: webapprouting.kubernetes.azure.com
11+
rules:
12+
- host: java-rag-aks-test4.eastus2.cloudapp.azure.com
13+
http:
14+
paths:
15+
- path: /api
16+
pathType: Prefix
17+
backend:
18+
service:
19+
name: backend-service
20+
port:
21+
number: 80
22+
- path: /
23+
pathType: Prefix
24+
backend:
25+
service:
26+
name: frontend-service
27+
port:
28+
number: 80
29+
tls:
30+
- hosts:
31+
- java-rag-aks-test4.eastus2.cloudapp.azure.com
32+
secretName: keyvault-ingress-api

deploy/aks/scripts/prepdocs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ echo 'Building java indexer'
1616
mvn package -f ../../app/indexer/pom.xml
1717

1818
echo 'Running the java indexer cli.jar'
19-
java -jar ../../app/indexer/cli/target/cli.jar '../../data' --verbose --storageaccount "$AZURE_STORAGE_ACCOUNT" --container "$AZURE_STORAGE_CONTAINER" --searchservice "$AZURE_SEARCH_SERVICE" --openai-service-name "$AZURE_OPENAI_SERVICE" --openai-emb-deployment "$AZURE_OPENAI_EMB_DEPLOYMENT" --index "$AZURE_SEARCH_INDEX" --formrecognizerservice "$AZURE_FORMRECOGNIZER_SERVICE" upload
19+
java -jar ../../app/indexer/cli/target/cli.jar '../../data' --verbose --storageaccount "$AZURE_STORAGE_ACCOUNT" --container "$AZURE_STORAGE_CONTAINER" --searchservice "$AZURE_SEARCH_SERVICE" --openai-service-name "$AZURE_OPENAI_SERVICE" --openai-emb-deployment "$AZURE_OPENAI_EMB_DEPLOYMENT" --index "$AZURE_SEARCH_INDEX" --document-intelligent-service "$AZURE_DOCUMENT_INTELLIGENCE_SERVICE" upload

deploy/aks/scripts/set_ingress_tls.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ if ($certificate) {
101101

102102

103103
# Enable azure key vault as Secrets Store CSI driver for application routing add-on enabled
104-
$keyVaultId = az keyvault show --name $kvName --query id -o tsv
104+
$keyVaultId = az keyvault show -g $clusterRG --name $kvName --query id -o tsv
105105

106106
$secretsProvider = az aks show -g $clusterRG -n $clusterName --query "addonProfiles.azureKeyvaultSecretsProvider" -o json | ConvertFrom-Json
107107

@@ -114,7 +114,7 @@ if ($secretsProvider -and $secretsProvider.PSObject.Properties['enabled'] -and (
114114
$IngressServicePrincipalID = az ad sp list --display-name "webapprouting-$clusterName" --query "[].id" --output tsv
115115

116116
Write-Host "Assigning Key Vault access policies to the Ingress Service Principal [$IngressServicePrincipalID] for Key Vault [$kvName]"
117-
az keyvault set-policy --name $kvName --object-id $IngressServicePrincipalID --secret-permissions get list --certificate-permissions get list
117+
az keyvault set-policy -g $clusterRG --name $kvName --object-id $IngressServicePrincipalID --secret-permissions get list --certificate-permissions get list
118118
}
119119

120120

deploy/aks/scripts/set_ingress_tls.sh

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ echo "Configure DNS for cluster Public IP using $appHostName"
5858
nodeRG=$(az aks show -n $clusterName -g $clusterRG -o json | jq -r '.nodeResourceGroup')
5959
echo "AKS Cluster is in resource group: $nodeRG"
6060

61-
ingressIP=$(kubectl get ingress ingress-api -n azure-open-ai -o jsonpath="{.status.loadBalancer.ingress[0].ip}")
61+
ingressIP=$(kubectl get ingress ingress-api -n java-rag-ns -o jsonpath="{.status.loadBalancer.ingress[0].ip}")
6262

6363
if [ -z "$ingressIP" ]; then
6464
echo "Please retry once Ingress Address is assigned to the AKS Cluster"
@@ -68,7 +68,7 @@ fi
6868
echo "Found Ingress IP: $ingressIP"
6969

7070
# List public IP resources in the specified resource group
71-
ipName=$(az network.public-ip list -g $nodeRG -o json | jq -c ".[] | select(.ipAddress | contains(\"$ingressIP\"))" | jq '.name' -r)
71+
ipName=$(az network public-ip list -g $nodeRG -o json | jq -c ".[] | select(.ipAddress | contains(\"$ingressIP\"))" | jq '.name' -r)
7272
echo "Public-ip IP Name within RG is: $ipName"
7373

7474
# Add a DNS name ($adAppName) to the public IP address
@@ -102,8 +102,11 @@ else
102102
if [ -f "aks-ingress-tls.pfx" ]; then
103103
echo "aks-ingress-tls.pfx found."
104104
else
105-
echo "Please create a aks-ingress-tls.pfx. For more info see https://learn.microsoft.com/en-us/azure/aks/app-routing-dns-ssl#create-and-export-a-self-signed-ssl-certificate"
106-
exit 1
105+
echo "aks-ingress-tls.pfx not found... trying to create a new for the hostname $appHostName"
106+
openssl req -new -x509 -nodes -out aks-ingress-tls.crt -keyout aks-ingress-tls.key -subj "/CN=$appHostName" -addext "subjectAltName=DNS:$appHostName"
107+
echo "Creating aks-ingress-tls.pfx from aks-ingress-tls.crt and aks-ingress-tls.key"
108+
openssl pkcs12 -export -in aks-ingress-tls.crt -inkey aks-ingress-tls.key -out aks-ingress-tls.pfx
109+
echo "aks-ingress-tls.pfx created successfully."
107110
fi
108111

109112
# Import the PFX file into Azure Key Vault
@@ -112,22 +115,22 @@ else
112115
fi
113116

114117
# Enable azure key vault as Secrets Store CSI driver for application routing add-on enabled
115-
keyVaultId=$(az keyvault show --name $kvName --query id -o tsv)
118+
keyVaultId=$(az keyvault show -g $clusterRG --name $kvName --query id -o tsv)
116119

117120
secretsProvider=$(az aks show -g $clusterRG -n $clusterName --query "addonProfiles.azureKeyvaultSecretsProvider" -o json)
118121
secretsProviderEnabled=$(echo $secretsProvider | jq -r '.enabled // false')
119122

120-
if [ "$secretsProviderEnabled" = "true" ]; then
121-
echo "Azure Key Vault Secrets Provider add-on is ENABLED"
122-
else
123+
#if [ "$secretsProviderEnabled" = "true" ]; then
124+
# echo "Azure Key Vault Secrets Provider add-on is ENABLED"
125+
#else
123126
echo "Enabling Azure Key Vault Secrets Provider add-on for aks ingress. KeyVault Id[$keyVaultId]"
124127
az aks approuting update -g $clusterRG -n $clusterName --enable-kv --attach-kv $keyVaultId
125128

126129
IngressServicePrincipalID=$(az ad sp list --display-name "webapprouting-$clusterName" --query "[].id" --output tsv)
127130

128131
echo "Assigning Key Vault access policies to the Ingress Service Principal [$IngressServicePrincipalID] for Key Vault [$kvName]"
129-
az keyvault set-policy --name $kvName --object-id $IngressServicePrincipalID --secret-permissions get list --certificate-permissions get list
130-
fi
132+
az keyvault set-policy -g $clusterRG --name $kvName --object-id $IngressServicePrincipalID --secret-permissions get list --certificate-permissions get list
133+
#fi
131134

132135
# Create the Ingress resource with TLS configuration
133136
certUri="https://$kvName.vault.azure.net/certificates/aks-ingress-tls"

docs/aca/README-ACA.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ However, you can try the [Azure pricing calculator](https://azure.com/e/8ffbe5b1
310310
The first 180,000 vCPU-seconds, 360,000 GiB-seconds, and 2 million requests each month are free for ACA. To reduce costs, you can switch to free SKUs Document Intelligence by changing the parameters file under the `infra` folder. There are some limits to consider; for example, the free Document Intelligence resource only analyzes the first 2 pages of each document.
311311
312312
⚠️ To avoid unnecessary costs, remember to take down your app if it's no longer in use,
313-
either by deleting the resource group in the Portal or running `azd down`.
313+
either by deleting the resource group in the Portal or running `azd down --purge`.
314314

315315
### Note
316316

docs/aca/login_and_acl.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The [azure-search-openai-demo-java](/) project can set up a full RAG chat app on
2222

2323
This guide demonstrates how to add an optional login and document level access control system to the sample. This system can be used to restrict access to indexed data to specific users based their [user object id](https://learn.microsoft.com/partner-center/find-ids-and-domain-names#find-the-user-object-id).
2424

25-
![AppLoginArchitecture](/docs/images/applogincomponents.png)
25+
![AppLoginArchitecture](/docs/applogincomponents.png)
2626

2727
## Requirements
2828

docs/aks/README-AKS.md

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,25 @@ For detailed instructions, see [Getting Started](#getting-started) below.
2323

2424
<!-- TOC -->
2525
- [Getting Started](#getting-started)
26-
* [Run in GitHub Codespaces or VS Code Dev Containers](#run-in-github-codespaces-or-vs-code-dev-containers)
26+
- [Run in GitHub Codespaces or VS Code Dev Containers](#run-in-github-codespaces-or-vs-code-dev-containers)
2727
- [Prerequisites](#prerequisites)
2828
- [Starting from scratch](#starting-from-scratch)
2929
- [Deploying with existing Azure resources](#deploying-with-existing-azure-resources)
3030
- [Existing resource group](#existing-resource-group)
3131
- [Existing OpenAI resource](#existing-openai-resource)
32-
- [Existing Azure Azure AI Search resource](#existing-azure-ai-search-resource)
32+
- [Existing Azure AI Search resource](#existing-azure-ai-search-resource)
3333
- [Other existing Azure resources](#other-existing-azure-resources)
3434
- [Provision remaining resources](#provision-remaining-resources)
35-
- [Deploying again](#redeploying)
36-
- [Running locally](#running-locally)
35+
- [Redeploying](#redeploying)
36+
- [Examples of an azd deployment changing the default chatgpt deployment model](#examples-of-an-azd-deployment-changing-the-default-chatgpt-deployment-model)
37+
- [Examples of an azd deployment reusing an existing Azure OpenAI and Azure AI Search resources](#examples-of-an-azd-deployment-reusing-an-existing-azure-openai-and-azure-ai-search-resources)
3738
- [UI Navigation](#ui-navigation)
3839
- [Guidance](#guidance)
3940
- [Enabling Application Insights](#enabling-application-insights)
40-
- [Enabling authentication](#enabling-authentication)
41+
- [Enabling login and search filtering](#enabling-login-and-search-filtering)
42+
- [Enabling client-side chat history](#enabling-client-side-chat-history)
43+
- [Enabling persistent chat history with Azure Cosmos DB](#enabling-persistent-chat-history-with-azure-cosmos-db)
4144
- [App Continuous Integration](#app-continuous-integration)
42-
- [GitHub](#github)
43-
- [Azure DevOps](#azure-devops)
44-
- [Custom Data Ingestion and Indexing](#custom-data-ingestion-and-indexing)
4545
- [Productionizing](#productionizing)
4646
- [Cost estimation](#cost-estimation)
4747
- [Note](#note)
@@ -72,7 +72,7 @@ All prerequisites are already installed in the container. You can skip to the [S
7272
- **Important**: Ensure you can run `pwsh.exe` from a PowerShell command. If this fails, you likely need to upgrade PowerShell.
7373
- [Docker Desktop](https://www.docker.com/products/docker-desktop/) or other docker agents
7474
- [Helm](https://helm.sh/docs/intro/install/)
75-
- _[K9s](https://k9scli.io/topics/install/) For K8s management - Optional_
75+
- [K9s](https://k9scli.io/topics/install/) For K8s management - Optional
7676

7777
> [!WARNING] Your Azure Account must have `Microsoft.Authorization/roleAssignments/write` permissions, such as [User Access Administrator](https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#user-access-administrator) or [Owner](https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#owner).
7878
@@ -106,6 +106,10 @@ It will look like the following:
106106

107107
!['Output from running azd up'](aks-deploy-success.png)
108108

109+
4. When you enable login and ACL, the https url will be printed in the console output, and you can use that to access the application. For more information on enabling login and ACL, see [here](./login_and_acl.md).
110+
111+
!['Output from running azd up with login and ACL enabled'](aks-deploy-success-login.png)
112+
109113
> NOTE: It may take a minute for the application to be fully deployed.
110114
111115
### Deploying with existing Azure resources
@@ -187,22 +191,6 @@ azd env set AZURE_SEARCH_SERVICE_LOCATION "eastus2" # Region of the ACS service
187191

188192
azd up
189193
```
190-
### Running locally
191-
192-
1. Run
193-
194-
```shell
195-
az login
196-
```
197-
198-
2. Change dir to `deploy/aks`
199-
200-
```shell
201-
cd deploy/aks
202-
```
203-
204-
3. Run the `./start-compose.ps1` (Windows) or `./start-compose.sh` (Linux/Mac) scripts or run the "VS Code Task: Start App" to start the project locally.
205-
4. Wait for the docker compose to start all the containers (web, api, indexer) and refresh your browser to [http://localhost](http://localhost)
206194

207195
### UI Navigation
208196

@@ -232,30 +220,34 @@ Under "Trace & Events" panel you can review custom Java informational logs to be
232220

233221
To see any exceptions and server errors, navigate to the "Investigate -> Failures" blade and use the filtering tools to locate a specific exception. You can see Java stack traces on the right-hand side.
234222

235-
### Enabling authentication
223+
### Enabling login and search filtering
224+
225+
See [here](./login_and_acl.md) for detailed guidance.
226+
227+
### Enabling client-side chat history
228+
229+
This feature allows users to view the chat history of their conversation, stored in the browser using [IndexedDB](https://developer.mozilla.org/docs/Web/API/IndexedDB_API). That means the chat history will be available only on the device where the chat was initiated. To enable browser-stored chat history, run:
236230

237231
```shell
238-
azd env set AZURE_USE_EASY_AUTH true
232+
azd env set USE_CHAT_HISTORY_BROWSER true
239233
```
234+
This is useful especially for unauthenticated users. For authenticated ones see below.
240235

241-
By default, the deployed apps on AKS will have no authentication or access restrictions enabled, meaning anyone with routable network access to the web app can chat with your indexed data. If you enable easy authentication the deployment will use a script based on [EasyAuthForK8s](https://github.com/Azure/EasyAuthForK8s) and using [Cert Manager](https://cert-manager.io/) to manage easy authentication for you using Microsoft Entra.
236+
### Enabling persistent chat history with Azure Cosmos DB
242237

243-
To then limit access to a specific set of users or groups, you can follow the steps from [Restrict your Microsoft Entra app to a set of users](https://learn.microsoft.com/entra/identity-platform/howto-restrict-your-app-to-a-set-of-users) by changing "Assignment Required?" option under the Enterprise Application, and then assigning users/groups access. Users not granted explicit access will receive the error message -AADSTS50105: Your administrator has configured the application <app_name> to block users
238+
This feature allows authenticated users to view the chat history of their conversations, stored in the server-side storage using [Azure Cosmos DB](https://learn.microsoft.com/azure/cosmos-db/).This option requires that authentication be enabled. The chat history will be persistent and accessible from any device where the user logs in with the same account. To enable server-stored chat history, run:
244239

245-
### App Continuous Integration
240+
```shell
241+
azd env set USE_CHAT_HISTORY_COSMOS true
242+
```
246243

247-
:sunny: :cloud: :construction_worker_man: WIP
244+
When both the browser-stored and Cosmos DB options are enabled, Cosmos DB will take precedence over browser-stored chat history.
248245

249-
### Custom Data Ingestion and Indexing
250246

251-
The repository includes sample pdf documents in the data folder. They are ingested in blob container and then indexed in Azure AI Search during infra provisioning by Azure Developer CLI post provision hooks.
247+
### App Continuous Integration
252248

253-
If you want to chat with your custom documents you can:
249+
:sunny: :cloud: :construction_worker_man: WIP
254250

255-
1. Add your pdf documents in the [data folder](../../data).
256-
2. Open a terminal and cd to repo root folder for app service deployment. Example `cd path/to/your/custom/dir/azure-search-openai-demo-java/deploy/aks`
257-
3. Run `./scripts/prepdocs.ps1` if you are on windows or `./scripts/prepdocs.sh` on linux
258-
4. Wait few minutes after the script complete so that the ingestion process, running on the indexer app, will ingest all the documents. This is not a 'delta' process, it's not updating **only** the new files you've added. Instead, on each run, all documents in data folder will be ingested. Feel free to add new files you want to ingest and delete/move the old documents from the data folder. Once you've run the script and it completes successfully, Azure AI Search index has been updated and stored (until you want to manually delete it from your azure Azure AI Search instance)
259251

260252
### Productionizing
261253

@@ -307,7 +299,7 @@ However, you can try the [Azure pricing calculator](https://azure.com/e/8ffbe5b1
307299
To reduce costs, you can switch to free SKUs Form Recognizer by changing the parameters file under the `infra` folder. There are some limits to consider; for example, the free Form Recognizer resource only analyzes the first 2 pages of each document. You can also reduce costs associated with the Form Recognizer by reducing the number of documents in the `data` folder, or changing the code to use the Itext document based parser, or by removing the postprovision hook in `azure.yaml` that runs the `indexer java cli`.
308300

309301
⚠️ To avoid unnecessary costs, remember to take down your app if it's no longer in use,
310-
either by deleting the resource group in the Portal or running `azd down`.
302+
either by deleting the resource group in the Portal or running `azd down --purge`.
311303

312304
### Note
313305

65.8 KB
Loading

0 commit comments

Comments
 (0)