Lab 16 - Enabling Advanced Data Analytics on Business Database and Answering Questions Using Azure OpenAI Service
Lab 16 - Enabling Advanced Data Analytics on Business Database and Answering Questions Using Azure OpenAI Service
This lab delves into the integration of Azure OpenAI capabilities to answer business
questions through advanced data analytics performed on a business database.
Leveraging the power of Open AI, such as ChatGPT/GPT-4, you’ll learn to construct
complex queries and glean insights from the data. The lab showcases the application's
versatility by addressing questions of varying complexity, such as revenue trends and
forecasting.
This integration supports both Python's built-in SQLITE and Microsoft SQL Server,
providing a comprehensive analytical toolset for businesses.
Objectives
Important: You can proceed with this lab only GPT-4 is available on your Azure OpenAI
Service. If it is not approved, you can request access to GPT-4 https://aka.ms/oai/get-gpt4
1. In Azure portal, click on portal menu represented by three horizontal bars on the
top left corner of page, as shown in the below image.
2. Navigate and click on + Create a resource.
3. On Create a resource page, in the Search services and marketplace search bar,
type Azure OpenAI, then press the Enter button.
4. In the Marketplace page, navigate to the Azure OpenAI tile, click on the V chevron
button beside Create, then navigate and click on the Azure OpenAI as shown in the
below image.
5. In the Create Azure OpenAI window, under the Basics tab, enter the following
details and click on the Next button.
Subscription Select your subscription
Resource group Click on Create new> enter AOAI-RGXX
(XX can be a unique number)
Region Select West US
Name azure-openai-testXX (XX can be a unique
number)
Pricing tier Select Standard S0
6. In the Network tab, leave all the radio buttons in the default state, and click on the
Next button.
7. In the Tags tab, leave all the fields in the default state, and click on the Next button.
8. In the Review + submit tab, once the Validation is Passed, click on the Create
button.
9. Wait for the deployment to complete. The deployment will take around 2-3 minutes.
10. On Microsoft.CognitiveServicesOpenAI window, after the deployment is
completed, click on Go to resource button.
Task 2: Deploy the models in Azure OpenAI
5. In the Deploy model dialog box, under the Model name field, click on the V
chevron button; navigate and select carefully gpt-35-turbo.
6. Select the Model version as Auto-update to default, in the Deployment name
field, enter gpt-35-turbo, and click on the Create button.
7. You will see a notification – Successfully Created deployment when the
deployment is succeeded (You can also view the notification by clicking on the bell
icon beside Azure AI | Azure AI Studio).
1. Open your browser, navigate to the address bar, and type or paste the following
URL: https://portal.azure.com/#create/Microsoft.AzureSQL then press the Enter
button.
2. Navigate to SQL databases section, ensure that Single database is selected under
Resource type, then click on the Create button.
10. In aoaisql (aoaisql29/aoaisql) page, copy SQL database and Server name and
paste them on a notepad (as shown in the below image), and then Save the notepad
to use the information in the upcoming lab.
Task 3: Configure and use the demo application for SQL query translation and
advanced data analysis
1. Open your browser, navigate to the address bar, and type or paste the following
URL: https://app-web-ulajovkr7vyd4.azurewebsites.net/ then press the Enter button.
2. On the web app page, in the left side navigation menu, click on Settings button.
3. Under Azure OpenAI Settings, enter the below details and then click on the Submit
button.
ChatGPT deployment name gpt-35-turbo
GPT-4 deployment name (if not gpt-4
specified, default to ChatGPT's)
Azure OpenAI Endpoint: Enter Azure OpenAI Service Endpoint (Endpoint
information that you have saved on your notepad
in Lab #1)
Azure OpenAI Key Enter Azure OpenAI Key (Key information that you
have saved on your notepad in Lab #1)
SQL Server aoaisqlXX.database.windows.net (SQL Server
information that you have saved on your notepad
in Task 1 of this lab)
Database aoaisql (Database information that you have
saved on your notepad in Task 1 of this lab)
User Aoaiuser
Password Password321!
4. There are two applications
5. Use SQL Query Writing Assistant in the web app page - Under Choose the app,
select SQL Query Writing Assistant radio button, select GPT Model as ChatGPT
then select Show code box. Under Ask me a question text box, enter the following
question and click on the Submit button.
Show me revenue by product in ascending order
6. Use SQL Query Writing Assistant in the web app page - Under Choose the app,
select SQL Query Writing Assistant radio button, select GPT Model as GPT 4 then
select Show code box. Under Ask me a question text box, enter the following
question and click on the Submit button.
Pick top 20 customers generated most revenue in 2016 and for each
customer show 3 products that they purchased most
7. Now, use Data Analyst Assistant in the web app page - Under Choose the app,
select Data Analysis Assistant radio button, select GPT Model as GPT 4 then
select Show code box and Show prompt. Under Ask me a question text box, enter
the following question and click on the Submit button.
Pick top 20 customers generated most revenue in 2016 and for each
customer show 3 products that they purchased most
8. Now, use Data Analyst Assistant in the web app page - Under Choose the app,
select Data Analysis Assistant radio button, select GPT Model as Chat GPT then
select Show code box. Under Ask me a question text box, enter the following
question and click on the Submit button.
Predict monthly revenue for next 6 months starting from June 2018. Do not
use Prophet.
Task 4: Delete the deployed model
1. In Azure OpenAI Studio, on the left pane, under the Management section, click on
Deployments. Select gpt-35-turbo deployment name and click on Delete
deployment.
2. In the Confirm delete dialog box, click on the Delete button. You will see the
notification – Successfully Deleted deployment.
1. To delete the SQL database and server, navigate to Azure portal Home page, click
on Resource groups.
4. In the Resource group page, navigate to command bar and click on Delete.
Note: In case, you did not see the Delete option on the command bar, then click on
the horizontal ellipsis, navigate and click on delete.
5. In the Delete Resources pane that appears on the right side, enter delete and then
click on Delete button.
6. On Delete confirmation dialog box, click on the Delete button.
7. Click on the bell icon, you’ll see the notification – Executed delete command on 2
selected items.
Summary
In this lab, you’ve deployed gpt-35-turbo model in Azure AI Studio and created
an Azure SQL Database with relevant configurations. Then, you’ve configured the hosted
demo application. You've used SQL Query Writing Assistant of the demo app to
translate business question into SQL query language, then executed it and viewed the
result. Then, you've used Data Analysis Assistant of the hosted demo app to perform
advanced data analytics. You've deleted the gpt-3-turbo model, SQL database, and SQL
server to effectively and efficiently manage the Azure OpenAI resources.
Important Note: Please do not delete the Resource Group. If deleted, you’ll not be
able to proceed with the next lab or create a new Resource Group.
Please do not delete the Azure OpenAI Service (Azure-openai-testXX). The same
service will be used throughout all the labs.