Skip to content

Commit 5c6ce97

Browse files
Merge pull request #255362 from KarlErickson/karler-maly7
Add AI service to fitness store quickstart
2 parents 4b00d13 + 8c2bacf commit 5c6ce97

12 files changed

+174
-3
lines changed
135 KB
Loading
14 KB
Loading
-3.41 KB
Loading

articles/spring-apps/quickstart-automate-deployments-github-actions-enterprise.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,4 @@ Continue on to any of the following optional quickstarts:
143143
- [Load application secrets using Key Vault](quickstart-key-vault-enterprise.md)
144144
- [Monitor applications end-to-end](quickstart-monitor-end-to-end-enterprise.md)
145145
- [Set request rate limits](quickstart-set-request-rate-limits-enterprise.md)
146+
- [Integrate Azure Open AI](quickstart-fitness-store-azure-openai.md)

articles/spring-apps/quickstart-deploy-apps-enterprise.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,3 +443,4 @@ Now that you've successfully built and deployed your app, continue on to any of
443443
- [Monitor applications end-to-end](quickstart-monitor-end-to-end-enterprise.md)
444444
- [Set request rate limits](quickstart-set-request-rate-limits-enterprise.md)
445445
- [Automate deployments](quickstart-automate-deployments-github-actions-enterprise.md)
446+
- [Integrate Azure Open AI](quickstart-fitness-store-azure-openai.md)
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
---
2+
title: "Quickstart - Integrate Azure OpenAI"
3+
titleSuffix: Azure Spring Apps Enterprise plan
4+
description: Explains how to integrate Azure OpenAI on the Azure Spring Apps Enterprise plan.
5+
author: KarlErickson # external contributor maly7
6+
ms.author: karler
7+
ms.service: spring-apps
8+
ms.topic: quickstart
9+
ms.date: 11/02/2023
10+
ms.custom: devx-track-java, devx-track-extended-java
11+
---
12+
13+
# Quickstart: Integrate Azure OpenAI
14+
15+
> [!NOTE]
16+
> Azure Spring Apps is the new name for the Azure Spring Cloud service. Although the service has a new name, you'll see the old name in some places for a while as we work to update assets such as screenshots, videos, and diagrams.
17+
18+
**This article applies to:** ❌ Basic/Standard ✔️ Enterprise
19+
20+
This quickstart shows you how to integrate Azure OpenAI with applications deployed on the Azure Spring Apps Enterprise plan.
21+
22+
Azure OpenAI enables your applications to take advantage of large-scale, generative AI models with deep understandings of language and code to enable new reasoning and comprehension capabilities.
23+
24+
## Prerequisites
25+
26+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
27+
- Access granted to Azure OpenAI. For more information, see [Request Access to Azure OpenAI Service](https://customervoice.microsoft.com/Pages/ResponsePage.aspx?id=v4j5cvGGr0GRqy180BHbR7en2Ais5pxKtso_Pz4b1_xUOFA5Qk1UWDRBMjg0WFhPMkIzTzhKQ1dWNyQlQCN0PWcu).
28+
- Understand and fulfill the [Requirements](how-to-enterprise-marketplace-offer.md#requirements) section of [Enterprise plan in Azure Marketplace](how-to-enterprise-marketplace-offer.md).
29+
- [The Azure CLI version 2.45.0 or higher](/cli/azure/install-azure-cli).
30+
- [Git](https://git-scm.com/).
31+
- [jq](https://stedolan.github.io/jq/download/)
32+
- [!INCLUDE [install-enterprise-extension](includes/install-enterprise-extension.md)]
33+
- Complete the steps in [Build and deploy apps to Azure Spring Apps using the Enterprise plan](quickstart-deploy-apps-enterprise.md).
34+
35+
## Provision Azure OpenAI
36+
37+
To add AI to the application, create an Azure OpenAI account and deploy language models. The following steps describe how to provision an Azure OpenAI account and deploy language models using the Azure CLI:
38+
39+
1. Use the following command to create an Azure OpenAI account:
40+
41+
```azurecli
42+
az cognitiveservices account create \
43+
--resource-group <resource-group-name> \
44+
--name <open-ai-service-name> \
45+
--location <region> \
46+
--kind OpenAI \
47+
--sku s0 \
48+
--custom-domain <open-ai-service-name>
49+
```
50+
51+
1. Use the following commands to create the model deployments for `text-embedding-ada-002` and `gpt-35-turbo-16k` in your Azure OpenAI service instance:
52+
53+
```azurecli
54+
az cognitiveservices account deployment create \
55+
--resource-group <resource-group-name> \
56+
--name <open-ai-service-name> \
57+
--deployment-name text-embedding-ada-002 \
58+
--model-name text-embedding-ada-002 \
59+
--model-version "2" \
60+
--model-format OpenAI \
61+
--sku-name "Standard" \
62+
--sku-capacity 1
63+
64+
az cognitiveservices account deployment create \
65+
--resource-group <resource-group-name> \
66+
--name <open-ai-service-name> \
67+
--deployment-name gpt-35-turbo-16k \
68+
--model-name gpt-35-turbo-16k \
69+
--model-version "0613" \
70+
--model-format OpenAI \
71+
--sku-name "Standard" \
72+
--sku-capacity 1
73+
```
74+
75+
### Deploy Assist Service to Azure Spring Apps
76+
77+
Use the following steps to create, configure, and deploy the Assist Service application to Azure Spring Apps.
78+
79+
1. Use the following command to create the new AI service, `assist-service`:
80+
81+
```azurecli
82+
az spring app create \
83+
--resource-group <resource-group-name> \
84+
--name assist-service \
85+
--service <Azure-Spring-Apps-service-instance-name> \
86+
--instance-count 1 \
87+
--memory 1Gi
88+
```
89+
90+
1. Use the following command to configure Spring Cloud Gateway with the Assist Service route:
91+
92+
```azurecli
93+
az spring gateway route-config create \
94+
--resource-group <resource-group-name> \
95+
--service <Azure-Spring-Apps-service-instance-name> \
96+
--name assist-routes \
97+
--app-name assist-service \
98+
--routes-file azure-spring-apps-enterprise/resources/json/routes/assist-service.json
99+
```
100+
101+
1. Use the following command to retrieve the REST API endpoint base URL for the Azure OpenAI service:
102+
103+
```azurecli
104+
export SPRING_AI_AZURE_OPENAI_ENDPOINT=$(az cognitiveservices account show \
105+
--name <open-ai-service-name> \
106+
--resource-group <resource-group-name> \
107+
| jq -r .properties.endpoint)
108+
```
109+
110+
1. Use the following command to retrieve the primary API key:
111+
112+
```azurecli
113+
export SPRING_AI_AZURE_OPENAI_APIKEY=$(az cognitiveservices account keys list \
114+
--name <open-ai-service-name> \
115+
--resource-group <resource-group-name> \
116+
| jq -r .key1)
117+
```
118+
119+
1. Use the following command to deploy the Assist Service application:
120+
121+
```azurecli
122+
az spring app deploy
123+
--resource-group <resource-group-name> \
124+
--name assist-service \
125+
--service <Azure-Spring-Apps-service-instance-name> \
126+
--source-path apps/acme-assist \
127+
--build-env BP_JVM_VERSION=17 \
128+
--env \
129+
SPRING_AI_AZURE_OPENAI_ENDPOINT=${SPRING_AI_AZURE_OPENAI_ENDPOINT} \
130+
SPRING_AI_AZURE_OPENAI_APIKEY=${SPRING_AI_AZURE_OPENAI_APIKEY} \
131+
SPRING_AI_AZURE_OPENAI_MODEL=gpt-35-turbo-16k \
132+
SPRING_AI_AZURE_OPENAI_EMBEDDINGMODEL=text-embedding-ada-002
133+
```
134+
135+
1. Now, test the Fitness Store application in the browser. Select **ASK TO FITASSIST** to converse with the Assist Service application.
136+
137+
:::image type="content" source="media/quickstart-fitness-store-azure-openai/homepage.png" alt-text="Screenshot that shows the ASK TO FITASSIST button." lightbox="media/quickstart-fitness-store-azure-openai/homepage.png":::
138+
139+
1. In **FitAssist**, enter *I need a bike for a commute to work* and observe the output that was generated by the Assist Service application:
140+
141+
:::image type="content" source="media/quickstart-fitness-store-azure-openai/fitassist-question.png" alt-text="Screenshot that shows the 'I need a bike for a commute to work' query and the response from the Fitness Store assistant." lightbox="media/quickstart-fitness-store-azure-openai/fitassist-question.png":::
142+
143+
## Clean up resources
144+
145+
If you plan to continue working with subsequent quickstarts and tutorials, you might want to leave these resources in place. When no longer needed, delete the resource group, which deletes the resources in the resource group. To delete the resource group by using Azure CLI, use the following commands:
146+
147+
```azurecli
148+
echo "Enter the Resource Group name:" &&
149+
read resourceGroupName &&
150+
az group delete --name $resourceGroupName &&
151+
echo "Press [ENTER] to continue ..."
152+
```
153+
154+
## Next steps
155+
156+
Continue on to any of the following optional quickstarts:
157+
158+
- [Configure single sign-on](quickstart-configure-single-sign-on-enterprise.md)
159+
- [Integrate Azure Database for PostgreSQL and Azure Cache for Redis](quickstart-integrate-azure-database-and-redis-enterprise.md)
160+
- [Load application secrets using Key Vault](quickstart-key-vault-enterprise.md)
161+
- [Monitor applications end-to-end](quickstart-monitor-end-to-end-enterprise.md)
162+
- [Automate deployments](quickstart-automate-deployments-github-actions-enterprise.md)

articles/spring-apps/quickstart-integrate-azure-database-and-redis-enterprise.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,3 +269,4 @@ Continue on to any of the following optional quickstarts:
269269
- [Monitor applications end-to-end](quickstart-monitor-end-to-end-enterprise.md)
270270
- [Set request rate limits](quickstart-set-request-rate-limits-enterprise.md)
271271
- [Automate deployments](quickstart-automate-deployments-github-actions-enterprise.md)
272+
- [Integrate Azure OpenAI](quickstart-fitness-store-azure-openai.md)

articles/spring-apps/quickstart-key-vault-enterprise.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,3 +340,4 @@ Continue on to any of the following optional quickstarts:
340340
- [Monitor applications end-to-end](quickstart-monitor-end-to-end-enterprise.md)
341341
- [Set request rate limits](quickstart-set-request-rate-limits-enterprise.md)
342342
- [Automate deployments](quickstart-automate-deployments-github-actions-enterprise.md)
343+
- [Integrate Azure OpenAI](quickstart-fitness-store-azure-openai.md)

articles/spring-apps/quickstart-monitor-end-to-end-enterprise.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,3 +321,4 @@ Continue on to any of the following optional quickstarts:
321321
- [Load application secrets using Key Vault](quickstart-key-vault-enterprise.md)
322322
- [Set request rate limits](quickstart-set-request-rate-limits-enterprise.md)
323323
- [Automate deployments](quickstart-automate-deployments-github-actions-enterprise.md)
324+
- [Integrate Azure OpenAI](quickstart-fitness-store-azure-openai.md)

articles/spring-apps/quickstart-sample-app-acme-fitness-store-introduction.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,17 @@ This quickstart describes the [fitness store](https://github.com/Azure-Samples/a
2424

2525
The following diagram shows a common application architecture:
2626

27-
:::image type="content" source="media/quickstart-sample-app-acme-fitness-store-introduction/architecture.png" alt-text="Diagram showing the architecture of the Fitness Store application." lightbox="media/quickstart-sample-app-acme-fitness-store-introduction/architecture.png" border="false":::
27+
:::image type="content" source="media/quickstart-sample-app-acme-fitness-store-introduction/architecture.png" alt-text="Diagram that shows the architecture of the Fitness Store application." lightbox="media/quickstart-sample-app-acme-fitness-store-introduction/architecture.png" border="false":::
2828

2929
This architecture shows an application composed of smaller applications with a gateway, multiple databases, security services, monitoring, and automation.
3030

3131
This quickstart applies this architecture to a Fitness Store application. This application is composed of the following services split up by domain:
3232

33-
- Three Java Spring Boot applications:
33+
- Four Java Spring Boot applications:
3434
- **Catalog Service** contains an API for fetching available products.
3535
- **Payment Service** validates and processes payments for users' orders.
3636
- **Identity Service** provides reference to the authenticated user.
37+
- **Assist Service** provides AI functionality to the fitness store.
3738

3839
- One Python application:
3940
- **Cart Service** manages users' items that have been selected for purchase.

0 commit comments

Comments
 (0)