Skip to content

Commit 3308370

Browse files
committed
updated readme and db folder structure
1 parent 2e425f8 commit 3308370

37 files changed

+234
-274
lines changed

README.MD

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,22 @@ Clean, easy and efficient.
4545

4646
The whole architecture is built using the following Azure services:
4747

48-
- [Azure SQL Database](https://learn.microsoft.com/en-us/azure/azure-sql/database/sql-database-paas-overview?view=azuresql): to store and query the samples data and embeddings.
49-
- [Azure Static Web Apps](https://learn.microsoft.com/en-us/azure/static-web-apps/overview): to host the full-stack application, including the front-end and the [backend API for Azure SQL](https://learn.microsoft.com/en-us/azure/static-web-apps/database-overview).
48+
- [Azure SQL Database](https://learn.microsoft.com/azure/azure-sql/database/sql-database-paas-overview?view=azuresql): to store and query the samples data and embeddings.
49+
- [Azure Static Web Apps](https://learn.microsoft.com/azure/static-web-apps/overview): to host the front-end application, and to provide reverse proxy to Data API builder.
50+
- [Azure Container Apps](https://learn.microsoft.com/azure/container-apps/overview): to host [Data API builder](https://learn.microsoft.com/en-us/azure/data-api-builder/overview), which is used to expose the database stored procedures as REST API.
5051
- [Azure OpenAI](https://learn.microsoft.com/azure/ai-services/openai/): to generate the embeddings for the samples data and to generate the results using the RAG pattern.
5152

5253
## Solution
5354

5455
### Pre-requisites
5556

5657
Local development is possible, but you still have to have an Azure OpenAI subscription to generate the embeddings and the results.
57-
All you need to have to run the sample locally is
58+
All you need to have to run the sample locally is:
5859

5960
- [Node](https://nodejs.org/en) - to run the front-end application.
60-
- [DotNet SDK 8](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) or later to run Data API builder and deploy the database.
61-
- [Static Web Apps CLI](https://learn.microsoft.com/en-us/azure/static-web-apps/static-web-apps-cli-overview) - to run the full-stack application locally.
61+
- [DotNet SDK 8](https://dotnet.microsoft.com/download/dotnet/8.0) or later to run Data API builder and deploy the database.
62+
- [Static Web Apps CLI](https://learn.microsoft.com/azure/static-web-apps/static-web-apps-cli-overview) - to run the full-stack application locally.
63+
- [Data API builder](https://learn.microsoft.com/azure/data-api-builder/how-to/install-cli) - to run the API locally.
6264

6365
### Azure Open AI
6466

@@ -67,7 +69,7 @@ Make sure to have two models deployed, one for generating embeddings (*text-embe
6769
- Embedding model: `text-embedding-3-small`
6870
- Chat model: `gpt-4o`, version `2024-08-06`
6971

70-
### Configure environment
72+
### Configure environment
7173

7274
Create a `.env` file starting from the `.env.sample` file:
7375

@@ -79,14 +81,11 @@ Create a `.env` file starting from the `.env.sample` file:
7981

8082
### Database
8183

82-
Since the database is using the new `vector` data type, you need use Azure SQL (you can use the [Free offer](https://learn.microsoft.com/en-us/azure/azure-sql/database/free-offer?view=azuresql)) or just announced [SQL database in Microsoft Fabric (Public Preview)](https://aka.ms/announcingsqlfabric) or the [SQL Server 2025 (EAP)](https://aka.ms/sqleapsignup).
83-
84-
> [!NOTE]
85-
> Vector Functions are in Public Preview. Learn the details about vectors in Azure SQL here: https://aka.ms/azure-sql-vector-public-preview
84+
Since the database is using the new `vector` data type, you need use Azure SQL (you can use the [Free offer](https://learn.microsoft.com/azure/azure-sql/database/free-offer?view=azuresql)) or just announced [SQL database in Microsoft Fabric (Public Preview)](https://aka.ms/announcingsqlfabric) or the [SQL Server 2025 (RC)](https://learn.microsoft.com/sql/sql-server/what-s-new-in-sql-server-2025?view=sql-server-ver17).
8685

8786
To deploy the database, make sure you have created the `.env` file as explained in the previoud section, and then run the following command:
8887

89-
```bash
88+
```bash
9089
dotnet run --project ./db
9190
```
9291

@@ -112,15 +111,21 @@ Once the database has been deployed, you can run the full-stack application loca
112111
cd client && npm install && cd ..
113112
```
114113

115-
Then, you can run the application locally using the Static Web Apps CLI. Make sure you have the `.env` file created as explained in the previous section, and then run the following command:
114+
Run the back-end API using Data API builder. Make sure you have created the `.env` file as explained in the previous section, and then run the following Powershell command:
115+
116+
```powershell
117+
dab start --config .\dab\dab-config.development.json
118+
```
119+
120+
Then, you can run the application locally using the Static Web Apps CLI. Make sure you have the `.env` file created as explained in the previous section, and then run the following command in a new terminal window:
116121

117122
```bash
118123
swa start
119124
```
120125

121126
Once the application is running, you can access it at `http://localhost:4280`.
122127

123-
Data API builder may take a few seconds to run if you are using Azure SQL and EntraID authentication. You can check if Data API builde is running by accessing `http://localhost:4280/data-api/rest/countSamples`.
128+
Data API builder may take a few seconds to run if you are using Azure SQL and EntraID authentication. You can check if Data API builde is running by accessing `http://localhost:4280/api/countSamples`.
124129

125130
### Azure deployment
126131

azure-sql-db-ai-samples-search.sln

Lines changed: 0 additions & 25 deletions
This file was deleted.

dab/dab-config.development.json

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
{
2+
"$schema": "https://github.com/Azure/data-api-builder/releases/download/v1.5.56/dab.draft.schema.json",
3+
"data-source": {
4+
"database-type": "mssql",
5+
"connection-string": "@env('MSSQL')",
6+
"options": {
7+
"set-session-context": false
8+
}
9+
},
210
"runtime": {
11+
"rest": {
12+
"enabled": true,
13+
"path": "/api",
14+
"request-body-strict": true
15+
},
16+
"graphql": {
17+
"enabled": false,
18+
"path": "/graphql",
19+
"allow-introspection": true
20+
},
321
"host": {
422
"cors": {
523
"origins": [],
@@ -9,6 +27,204 @@
927
"provider": "StaticWebApps"
1028
},
1129
"mode": "development"
30+
},
31+
"cache": {
32+
"enabled": true,
33+
"ttl-seconds": 1
34+
}
35+
},
36+
"entities": {
37+
"Samples": {
38+
"source": {
39+
"object": "dbo.samples",
40+
"type": "table"
41+
},
42+
"rest": {
43+
"enabled": true,
44+
"path": "/samples"
45+
},
46+
"permissions": [
47+
{
48+
"role": "anonymous",
49+
"actions": [
50+
{
51+
"action": "read"
52+
}
53+
]
54+
}
55+
]
56+
},
57+
"FindSamples": {
58+
"source": {
59+
"object": "web.find_samples",
60+
"type": "stored-procedure",
61+
"parameters": {
62+
"text": "",
63+
"k": 50,
64+
"debug": 0,
65+
"nocache": 0
66+
}
67+
},
68+
"graphql": {
69+
"enabled": false,
70+
"operation": "query",
71+
"type": {
72+
"singular": "FindSamples",
73+
"plural": "FindSamples"
74+
}
75+
},
76+
"rest": {
77+
"enabled": true,
78+
"path": "/findSamples",
79+
"methods": [
80+
"post", "get"
81+
]
82+
},
83+
"permissions": [
84+
{
85+
"role": "anonymous",
86+
"actions": [
87+
{
88+
"action": "*"
89+
}
90+
]
91+
}
92+
]
93+
},
94+
"SamplesCount": {
95+
"source": {
96+
"object": "web.get_total_sample_count",
97+
"type": "stored-procedure"
98+
},
99+
"graphql": {
100+
"enabled": false,
101+
"operation": "query",
102+
"type": {
103+
"singular": "SamplesCount",
104+
"plural": "SamplesCounts"
105+
}
106+
},
107+
"rest": {
108+
"enabled": true,
109+
"path": "/countSamples",
110+
"methods": [
111+
"post", "get"
112+
]
113+
},
114+
"permissions": [
115+
{
116+
"role": "anonymous",
117+
"actions": [
118+
{
119+
"action": "*"
120+
}
121+
]
122+
}
123+
]
124+
},
125+
"FindLatestSamples": {
126+
"source": {
127+
"object": "web.get_latest_samples",
128+
"type": "stored-procedure"
129+
},
130+
"rest": {
131+
"enabled": true,
132+
"path": "/latestSamples",
133+
"methods": [
134+
"post", "get"
135+
]
136+
},
137+
"permissions": [
138+
{
139+
"role": "anonymous",
140+
"actions": [
141+
{
142+
"action": "*"
143+
}
144+
]
145+
}
146+
]
147+
},
148+
"DeleteSample": {
149+
"source":{
150+
"object": "dbo.delete_sample",
151+
"type": "stored-procedure",
152+
"parameters": {
153+
"id": 0,
154+
"url": ""
155+
}
156+
},
157+
"rest": {
158+
"enabled": true,
159+
"path": "/deleteSample",
160+
"methods": [
161+
"delete"
162+
]
163+
},
164+
"permissions": [
165+
{
166+
"role": "admin",
167+
"actions": [
168+
{
169+
"action": "*"
170+
}
171+
]
172+
}
173+
]
174+
},
175+
"SampleDetails": {
176+
"source": {
177+
"object": "dbo.get_sample",
178+
"type": "stored-procedure",
179+
"parameters": {
180+
"id": 0,
181+
"url": ""
182+
}
183+
},
184+
"rest": {
185+
"enabled": true,
186+
"path": "/sampleDetails",
187+
"methods": [
188+
"get",
189+
"post"
190+
]
191+
},
192+
"permissions": [
193+
{
194+
"role": "anonymous",
195+
"actions": [
196+
{
197+
"action": "*"
198+
}
199+
]
200+
}
201+
]
202+
},
203+
"UpsertSample": {
204+
"source": {
205+
"object": "dbo.add_sample",
206+
"type": "stored-procedure",
207+
"parameters": {
208+
"payload": ""
209+
}
210+
},
211+
"rest": {
212+
"enabled": true,
213+
"path": "/upsertSample",
214+
"methods": [
215+
"post"
216+
]
217+
},
218+
"permissions": [
219+
{
220+
"role": "admin",
221+
"actions": [
222+
{
223+
"action": "*"
224+
}
225+
]
226+
}
227+
]
12228
}
13229
}
14230
}

0 commit comments

Comments
 (0)