Skip to content

Commit 99cd148

Browse files
committed
added production deployment section on README.md
1 parent e263577 commit 99cd148

File tree

5 files changed

+122
-0
lines changed

5 files changed

+122
-0
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,10 @@ Below you can find the list of available implementations.
6767
| Chat | [JavaSemanticKernelChainsApproach](https://github.com/Azure-Samples/azure-search-openai-demo-java/blob/main/app/backend/src/main/java/com/microsoft/openai/samples/rag/chat/approaches/semantickernel/JavaSemanticKernelChainsChatApproach.java) | Use Java Semantic Kernel framework with semantic and native functions chaining. It uses an imperative style for AI orchestration through semantic kernel functions chaining. [InformationFinder.SearchFromConversation](https://github.com/Azure-Samples/azure-search-openai-demo-java/blob/main/app/backend/src/main/java/com/microsoft/openai/samples/rag/retrieval/semantickernel/CognitiveSearchPlugin.java) native function and [RAG.AnswerConversation](https://github.com/Azure-Samples/azure-search-openai-demo-java/blob/main/app/backend/src/main/resources/semantickernel/Plugins/RAG/AnswerConversation/config.json) semantic function are called sequentially. Several search retrieval options are available: Text, Vector, Hybrid. | :x: | :white_check_mark: |
6868

6969

70+
## Production Deployment on Azure Applciation Landing Zones
71+
72+
This sample is designed to get you started quickly and let you experiment with Java intelligent Apps RAG architectures on Azure.For production deployment, you can use the [Azure Application Landing Zones (LZA)](https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/scenarios/app-platform/ready) to deploy the solution maintaining best practices for security, monitoring, networking and operational excellence.
73+
74+
Check the [chat-with-your-data-lza-app-accelerator](https://github.com/dantelmomsft/chat-with-your-data-java-lza-app-accelerator) to see how you can deploy this solution on App Service LZA or Azure Container Apps LZA.
75+
76+
![Azure Container Apps LZA deployment](docs/aca/aca-internal-java-ai.png)

app/backend/src/main/java/com/microsoft/openai/samples/rag/proxy/OpenAIProxy.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public ChatCompletions getChatCompletions(ChatCompletionsOptions chatCompletions
6969
e.getResponse().getStatusCode(),
7070
"Error calling OpenAI API:" + e.getMessage(),
7171
e);
72+
// ((Map)((Map)e.getValue()).get("error")).get("message")
7273
}
7374
return chatCompletions;
7475
}

deploy/aca/compose.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
services:
2+
frontend:
3+
image: ai-chat-reference-java/frontend
4+
build: ./frontend
5+
environment:
6+
REACT_APP_API_BASE_URL: "http://backend:8080"
7+
ports:
8+
- "80:80"
9+
backend:
10+
image: ai-chat-reference-java/backend
11+
build: ./backend
12+
environment:
13+
- AZURE_STORAGE_ACCOUNT=${AZURE_STORAGE_ACCOUNT}
14+
- AZURE_STORAGE_CONTAINER=${AZURE_STORAGE_CONTAINER}
15+
- AZURE_SEARCH_INDEX=${AZURE_SEARCH_INDEX}
16+
- AZURE_SEARCH_SERVICE=${AZURE_SEARCH_SERVICE}
17+
- AZURE_SEARCH_QUERY_LANGUAGE=${AZURE_SEARCH_QUERY_LANGUAGE}
18+
- AZURE_SEARCH_QUERY_SPELLER=${AZURE_SEARCH_QUERY_SPELLER}
19+
- AZURE_OPENAI_EMB_MODEL_NAME=${AZURE_OPENAI_EMB_MODEL_NAME}
20+
- AZURE_OPENAI_EMB_DEPLOYMENT=${AZURE_OPENAI_EMB_DEPLOYMENT}
21+
- AZURE_OPENAI_CHATGPT_MODEL=${AZURE_OPENAI_CHATGPT_MODEL}
22+
- AZURE_OPENAI_SERVICE=${AZURE_OPENAI_SERVICE}
23+
- AZURE_OPENAI_CHATGPT_DEPLOYMENT=${AZURE_OPENAI_CHATGPT_DEPLOYMENT}
24+
- spring_profiles_active=docker
25+
- AZURE_CLIENT_ID=${servicePrincipal}
26+
- AZURE_CLIENT_SECRET=${servicePrincipalPassword}
27+
- AZURE_TENANT_ID=${servicePrincipalTenant}
28+
ports:
29+
- "8080:8080"
30+
indexer:
31+
image: ai-chat-reference-java/indexer
32+
build:
33+
context: ./indexer
34+
dockerfile: microservice/Dockerfile
35+
environment:
36+
- AZURE_STORAGE_ACCOUNT=${AZURE_STORAGE_ACCOUNT}
37+
- AZURE_STORAGE_CONTAINER=${AZURE_STORAGE_CONTAINER}
38+
- AZURE_SEARCH_INDEX=${AZURE_SEARCH_INDEX}
39+
- AZURE_SEARCH_SERVICE=${AZURE_SEARCH_SERVICE}
40+
- AZURE_FORMRECOGNIZER_SERVICE=${AZURE_FORMRECOGNIZER_SERVICE}
41+
- AZURE_SEARCH_QUERY_SPELLER=${AZURE_SEARCH_QUERY_SPELLER}
42+
- AZURE_OPENAI_EMB_MODEL_NAME=${AZURE_OPENAI_EMB_MODEL_NAME}
43+
- AZURE_OPENAI_EMB_DEPLOYMENT=${AZURE_OPENAI_EMB_DEPLOYMENT}
44+
- AZURE_OPENAI_SERVICE=${AZURE_OPENAI_SERVICE}
45+
- AZURE_SERVICEBUS_NAMESPACE=${AZURE_SERVICEBUS_NAMESPACE}
46+
- spring_profiles_active=docker
47+
- SPRING_CONFIG_LOCATION=classpath:/local-dev.properties
48+
- AZURE_CLIENT_ID=${servicePrincipal}
49+
- AZURE_CLIENT_SECRET=${servicePrincipalPassword}
50+
- AZURE_TENANT_ID=${servicePrincipalTenant}
51+

deploy/aca/start-compose.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
echo ""
2+
echo "Loading azd .env file from current environment"
3+
echo ""
4+
5+
while IFS='=' read -r key value; do
6+
value=$(echo "$value" | sed 's/^"//' | sed 's/"$//')
7+
export "$key=$value"
8+
echo "export $key=$value"
9+
done <<EOF
10+
$(azd env get-values)
11+
EOF
12+
13+
if [ $? -ne 0 ]; then
14+
echo "Failed to load environment variables from azd environment"
15+
exit $?
16+
fi
17+
18+
echo ""
19+
echo "Checking Service Principal and get password"
20+
echo ""
21+
22+
roles=(
23+
"5e0bd9bd-7b93-4f28-af87-19fc36ad61bd"
24+
"a97b65f3-24c7-4388-baec-2e87135dc908"
25+
"2a2b9908-6ea1-4ae2-8e65-a410df84e7d1"
26+
"ba92f5b4-2d11-453d-a403-e96b0029c9fe"
27+
"1407120a-92aa-4202-b7e9-c0e197c71c8f"
28+
"8ebe5a00-799e-43f5-93ac-243d3dce84a7"
29+
"7ca78c08-252a-4471-8644-bb5ff32d4ba0"
30+
"4f6d3b9b-027b-4f4c-9142-0e5a2a2247e0"
31+
)
32+
33+
#Check if service principal exists
34+
export servicePrincipal=$(az ad sp list --display-name "azure-ai-chat-java-spi" --query [].appId --output tsv)
35+
36+
if [ -z "$servicePrincipal" ]; then
37+
echo "Service principal not found. Creating service principal"
38+
export servicePrincipal=$(az ad sp create-for-rbac --name "azure-ai-chat-java-spi" --role reader --scopes /subscriptions/"$AZURE_SUBSCRIPTION_ID"/resourceGroups/"$AZURE_RESOURCE_GROUP" --query appId --output tsv)
39+
if [ $? -ne 0 ]; then
40+
echo "Failed to create service principal"
41+
exit $?
42+
fi
43+
export servicePrincipalObjectId=$(az ad sp show --id "$servicePrincipal" --query id --output tsv)
44+
echo "Assigning Roles to service principal azure-ai-chat-java-spi with principal id:$servicePrincipal and object id[$servicePrincipalObjectId]"
45+
for role in "${roles[@]}"; do
46+
47+
echo "Assigning Role[$role] to principal id[$servicePrincipal] for resource[/subscriptions/"$AZURE_SUBSCRIPTION_ID"/resourceGroups/"$AZURE_RESOURCE_GROUP"] "
48+
az role assignment create \
49+
--role "$role" \
50+
--assignee-object-id "$servicePrincipalObjectId" \
51+
--scope /subscriptions/"$AZURE_SUBSCRIPTION_ID"/resourceGroups/"$AZURE_RESOURCE_GROUP" \
52+
--assignee-principal-type ServicePrincipal
53+
done
54+
fi
55+
56+
export servicePrincipalPassword=$(az ad sp credential reset --id "$servicePrincipal" --query password --output tsv)
57+
export servicePrincipalTenant=$(az ad sp show --id "$servicePrincipal" --query appOwnerOrganizationId --output tsv)
58+
59+
echo ""
60+
echo "Starting solution locally using docker compose. "
61+
echo ""
62+
63+
docker compose -f ./compose.yaml up

docs/aca/aca-internal-java-ai.png

183 KB
Loading

0 commit comments

Comments
 (0)