Skip to content

Latest commit

 

History

History
149 lines (82 loc) · 7.25 KB

Deploy-the-application-to-Azure.md

File metadata and controls

149 lines (82 loc) · 7.25 KB

Exercise 1: Open AI Setup and Installation of Application

Estimated Duration : 1 Hour

In this exercise, you will be setting up the Open AI resource and installation of the application to Azure.

Objectives

In this Exercise, you will complete the following tasks:

  • Task 1: Review Open AI resource
  • Task 2: Deploy the application to Azure

Task 1: Review Open AI resource

In this task, you will be reviewing the Open AI deployments.

  1. In the Azure portal, search for Azure OpenAI in the top search box then select Azure OpenAI under services.

  2. From the Azure AI Services | Azure OpenAI pane, select SQL-OpenAI-.

  3. In the Azure OpenAI resource pane, click on Go to Azure OpenAI Studio it will navigate to Azure AI Studio.

  4. In the Azure AI Studio, select Deployments (1) under Management and verify that gpt-35-turbo model is present with the deployment name as sql-chatgpt-model, review that the capacity of the model is set to 15K TPM. Copy the OpenAI Model name into the text file for later use.

    Note: Click on the Expand button, if you dont see the left side navigation pane.

  5. Naviagte back to Azure portal, search and select Azure OpenAI, from the Azure AI Services | Azure OpenAI pane, select the SQL-OpenAI-.

  6. Now select Keys and Endpoints (1) under Resource Management and click on Show Keys (2). Copy the KEY 1 (3) and Endpoint (4), and store them in a text file for later use.

    Note: If you dont see the Left side Navigation pane, click on the three horizontal line on the top left corner.

Task 2: Deploy the application to Azure

In this task, you will be reviewing the code in the visual studio code and publishing the application to Azure App Services through CLI.

  1. In the LabVM, open File Explorer naviagte to the C:\LabFiles\OpenAIWorkshop-Automation\scenarios\incubations\automating_analytics (1) path, right click on app.py (2), and select Open with Code (3). Take a look at the code to see how it works.

    • The provided code is a Streamlit application that consists of two main components: a SQL Query Writing Assistant and a Data Analysis Assistant. The application allows you to interact with an SQL database and perform various tasks.

    • The code begins with importing necessary libraries and dependencies such as Streamlit, Pandas, NumPy, Plotly, and others. It also imports custom modules like AnalyzeGPT, SQL_Query, and ChatGPT_Handler.

  2. If the pop up appears for Do you trust the authors of the file in this folder, click on Yes, I trust the authors.

  3. In the code snippet, you can configure Azure OpenAI deployment settings and optional SQL Server settings. It provides input fields for entering deployment names, endpoints, API keys, and SQL Server details. With Streamlit, you can save settings and customize the application's functionality. Settings allow you to customize the application's behavior based on your specific needs, enhancing the overall experience.

  4. The code snippet creates a chat interface using two GPT models, "ChatGPT" and "GPT-4". There are various models to choose from, FAQs specific to each model, and a form to ask questions. Moreover, the code includes options for showing the code and prompts, allowing you to interact with the chat interface more easily.

  5. There is a "Submit" button in the code snippet that triggers a series of checks and actions. It verifies that the necessary deployment settings and SQL server settings are provided. If all requirements are met, it creates an SQL query tool and an analyzer object. To run queries and display results, it uses different methods based on the index value.

  6. In the LabVM, navigate to Desktop and search for cmd in the search box then click on Command Prompt.

  7. Run the below command to change the directory.

    cd C:\LabFiles\OpenAIWorkshop-Automation
  8. Run the below command to Authenticate with Azure. It will redirect to Azure authorize website, select your account.

    azd auth login

    Note: The warnings can be ignored.

  9. Run the below command to setup the resource group deployment and Create a new environment. Make sure to replace {DeploymentId} with in the below command.

    azd config set alpha.resourceGroupDeployments on
    azd env new sql-chat-gpt-{DeploymentId}
  10. Run the below command to Provision Azure resources, and deploy your project with a single command.

    azd up
  11. Please select your Azure Subscription to use, enter 1 and click on the Enter button.

  12. Please select an Azure location to use, select the location as location, and click on the Enter button. You can change the location using the up and down arrow.

  13. Once the deployment succeeded, you will see the following message SUCCESS: Your application was provisioned and deployed to Azure. The deployment might take 5 - 10 minutes. It is producing a web package file, then creating the resource and publishing the package to the app service.

  14. Navigate back to the Azure portal, search and select App service.

  15. Select the available web app that you have deployed in the previous step.

  16. Next, click on Browse to open your Web application.

  17. Click the Next button located in the bottom right corner of this lab guide to continue with the next exercise.

    Congratulations on completing the task! Now, it's time to validate it. Here are the steps:

    • If you receive a success message, you can proceed to the next task.
    • If not, carefully read the error message and retry the step, following the instructions in the lab guide.
    • If you need any assistance, please contact us at [email protected]. We are available 24/7 to help you out.

Summary

In this exercise, you have completed the OpenAI Setup and hosted a demo application to Azure. You will be exploring the demo application in the next exercise, click Next to continue with the lab.

You have successfully completed the lab