Skip to content

Commit 5fe1b53

Browse files
committed
resolve PR comments, rev 2
1 parent 91f11b6 commit 5fe1b53

File tree

10 files changed

+684
-241
lines changed

10 files changed

+684
-241
lines changed

notebooks/GenAI/azure_infra_setup/README.md

Lines changed: 83 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,77 @@
1-
# Setting Up Azure Environment for Azure GenAI Cloud Lab
2-
3-
Welcome! This guide will help you set up your Azure environment to complete the activities in the [Azure GenAI](../) directory of the NIH Cloud Lab. We will walk you through the steps required to configure PowerShell, deploy necessary resources using an ARM template, upload local files to Azure Storage Account, and acquire keys and secrets for `.env` variables.
4-
5-
## Prerequisites
1+
# Setting Up Azure Environment for Azure GenAI Cloud Lab
2+
3+
This guide will help you set up your Azure environment to complete the activities in the [GenAI](../) directory of the NIH Cloud Lab.
4+
The purpose of this guide is to walk you through an automated deployment of the resources needed to carry out these activities.
5+
This automated approach utilizes a pre-built [ARM template](arm_resources.json) file, which serves as an alternative approach
6+
to manually deploying and configuring resources via the Azure portal.
7+
8+
## Page Contents
9+
+ [Learning Objectives](#learning_objectives)
10+
+ [Prerequisites](#prerequisites)
11+
+ [Resources and Pricing](#resources_and_pricing)
12+
+ [Get Started](#get_started)
13+
+ [Conclusion](#conclusion)
14+
+ [Clean Up](#clean_up)
15+
16+
## Learning Objectives <a name="learning_objectives"></a>
17+
18+
1. Configure PowerShell or Azure CLI
19+
- Step-by-step instructions to set up and configure PowerShell and Azure CLI for the neccessary Azure resource deployments.
20+
2. Deploy Resources Using an ARM Template
21+
- Detailed guidance on deploying the necessary resources in Azure using an ARM template for the [GenAI](../) directory.
22+
3. Upload Local Files to Azure Storage Account
23+
- Instructions on how to upload files from the [search_documents](../search_documents/) directory to an Azure Storage Account Blob container.
24+
4. Acquire Keys and Secrets for .env Variables
25+
- Steps to obtain keys and secrets from deployed resources and use them in your .env files for the tutorials in the [GenAI](../) directory.
26+
27+
## Prerequisites <a name="prerequisites"></a>
628

729
- An active Azure subscription
830
- PowerShell installed on your machine (option 1)
931
- Azure CLI installed (option 2)
32+
33+
### Powershell (option 1) vs. Azure CLI (option 2)
34+
35+
Choosing between Azure CLI and PowerShell comes down to personal preference and the working environment:
36+
37+
- **Cloud Environments**: For users working in the cloud, such as with Azure Machine Learning or Azure VMs, Azure CLI may be a more suitable option.
38+
- ***Note***: If users are utilizing any of these environments, please skip Step 1 and move directly to Step 2 using Azure CLI (option 2).
39+
- **Local Environments**: For users working on a local machine, both Azure CLI and PowerShell are viable options. The choice depends on personal preference.
40+
- ***Note***: If users are utilizing Azure CLI, please skip Step 1 and move directly to Step 2.
41+
42+
## Resources and Pricing <a name="resources_and_pricing"></a>
43+
44+
Provided is a list of resources that will be deployed by the provided ARM template along with the estimated cost breakdown for each resource.
45+
***An ARM Template is a JSON file that defines the infrastructure and configuration for your Azure project***. It allows you to deploy, manage, and configure
46+
all the resources for your solution in a single, coordinated operation. When executing the provided ARM template, actual costs may vary depending on usage
47+
and the Azure pricing model for each resource. Please find the resources that will be deployed below.
48+
49+
### Resources Deployed
50+
1. **Azure Storage Account**
51+
- **Resource Type**: Storage Account (Standard_LRS)
52+
- **Purpose**: This resource is used to store and manage files from [search_documents](../search_documents/) in a single container.
53+
- **Estimated Cost**: $0.018 per GB/$18.40 per 1000 GB per month
54+
55+
2. **Azure AI Search**
56+
- **Resource Type**: Cognitive Search (Basic)
57+
- **Purpose**: This resource provides AI search capabilities for the GenAI tutorials, including indexing and querying.
58+
- **Estimated Cost**: $0.10 per hour/$73.73 per month
59+
60+
3. **Azure OpenAI**
61+
- **Resource Type**: Cognitive Services (Standard)
62+
- **Purpose**: This resource provides access to OpenAI models, including GPT-4 and embeddings for AI processing.
63+
- **Models Deployed**:
64+
- **Model**: gpt-4o-mini
65+
- **Version**: 2024-07-18
66+
- **Cost per 1M Tokens**: $0.15 input/$0.60 output
67+
- **Model**: text-embedding-3-small
68+
- **Version**: 1
69+
- **Cost per 1K Tokens**: $0.00002
70+
- **Estimated Cost**: Varies based on model usage and API calls. Please refer to [Azure OpenAI Service Pricing](https://azure.microsoft.com/en-us/pricing/details/cognitive-services/openai-service/?msockid=3df6a53ac4916aa73e41b1e3c5c36bd4) for more details.
1071

11-
## Steps
72+
Please refer to the [Azure Pricing Calculator](https://azure.microsoft.com/en-us/pricing/calculator/) for a more detailed and personalized estimate based on your specific usage patterns and region.
73+
74+
## Get Started <a name="get_started"></a>
1275

1376
### 1. Setting Up the Azure Module in PowerShell
1477

@@ -17,9 +80,6 @@ First, you need to install the Azure module in PowerShell to connect to your Azu
1780
```powershell
1881
# Install the Az module (if using PowerShell)
1982
Install-Module -Name Az -AllowClobber -Force
20-
21-
# Import the Az module (if using Azure CLI)
22-
Import-Module Az
2383
```
2484

2585
### 2. Logging into Azure
@@ -32,7 +92,7 @@ You can log into your Azure account either using PowerShell or Azure CLI.
3292
Connect-AzAccount
3393
```
3494
**Using Azure CLI**
35-
```powershell
95+
```bash
3696
# Log into your Azure account
3797
az login
3898
```
@@ -83,7 +143,7 @@ az group create --name $resourceGroupName --location $location
83143

84144
### 5. Deploying the ARM Template
85145

86-
Deploy the [ARM template](/notebooks/GenAI/azure_infra_setup/arm_resources.json) to create the Azure Storage Account, Azure AI Search, and Azure OpenAI resources.
146+
Deploy the [ARM template](arm_resources.json) to create the Azure Storage Account, Azure AI Search, and Azure OpenAI resources.
87147

88148
***Using PowerShell***
89149
```powershell
@@ -123,7 +183,11 @@ done
123183

124184
### 7. Retrieving API Keys
125185

126-
Retrieve the API keys for each service created by the ARM template deployment. These secrets are confidential and should be handled appropriately. Once the output is received, the values will be added to your `.env` file, which should be created in the ./notebooks/GenAI directory. Note that this `.env` file is already added to the `.gitignore`.
186+
Retrieve the API keys for each service created by the ARM template deployment. These secrets are confidential and should be handled appropriately.
187+
Once the output is received, the values should be added to your `.env` file, which should be created in the [GenAI](../) directory.
188+
Note that this `.env` file is already added to the `.gitignore` file, which tells Git which files or directories to ignore in a project,
189+
preventing them from being tracked or included in version control. Adding `.env` to `.gitignore` is crucial because it prevents sensitive information
190+
like API keys and passwords from being exposed in your version control system.
127191

128192
**Azure Storage Account**
129193

@@ -221,14 +285,18 @@ AZURE_SEARCH_ADMIN_KEY = "Your Azure AI Search API key"
221285
BLOB_CONTAINER_NAME = "Your Azure Blob Container name hosting files from /search_documents"
222286
BLOB_CONNECTION_STRING = "Your Azure Blob connection string"
223287
```
224-
## Conclusion
288+
## Conclusion <a name="conclusion"></a>
225289

226-
Congratulations on completing the Azure setup! During this process, we established a new resource group dedicated to the NIH Cloud Lab environment and configured three Azure resources in your tenant using an ARM template file. The resources include:
290+
Congratulations on completing the Azure setup! During this process, we established a new resource group dedicated to the NIH Cloud Lab environment and
291+
configured three Azure resources in your tenant using an ARM template file. The resources include:
227292

228293
- An Azure Storage Account with a deployed Blob container and files uploaded from `../search_documents`
229294
- Azure AI Search
230295
- Azure OpenAI with deployed `gpt-4o-mini` and `text-embedding-3-small` models
231296

232297
Additionally, we configured `.env` variables in your local `.env` file, which is added to `.gitignore` by default.
233298

234-
You are now ready to proceed with the GenAI activities in the NIH Cloud Lab.
299+
You are now ready to proceed with the GenAI tutorials!
300+
301+
## Clean Up <a name="clean_up"></a>
302+
No clean up neccessary, as the created resources will be used for tutorials found in [GenAI](../).

notebooks/GenAI/embedding_demos/Demo_Suite.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ def main():
1515
st.title("Azure OpenAI RAG Demo Suite")
1616
st.markdown("### Demo Overviews")
1717
st.write("""
18-
Welcome to the Azure OpenAI RAG Demo Suite. On the left side-panel, you will find various demonstrations that showcase the capabilities of Azure OpenAI with a Streamlit frontend. Each demonstration is described in detail below, highlighting their unique features and functionalities.
18+
Welcome to the Azure OpenAI RAG Demo Suite. On the left side-panel, you will find various demonstrations that showcase the capabilities
19+
of Azure OpenAI with a Streamlit frontend. Each demonstration is described in detail below, highlighting their unique features and functionalities.
1920
""")
2021

2122
# Horizontal divider
@@ -24,7 +25,7 @@ def main():
2425
# Chat with Your Data section
2526
st.markdown("### Generate & Search with Azure OpenAI & Azure AI Search (AI Search Query)")
2627
st.write("""
27-
This demo provides an interactive platform for users to manage documents stored in their Azure Blob Container.
28+
This demo provides an interactive platform for users to chat over documents stored in their Azure Blob Container.
2829
This is accomplished by indexing the documents in Azure AI Search and employing a combination of semantic and vector search techniques.
2930
In this demo, we concentrate on real documents that are housed in an Azure Blob Container.
3031
These documents undergo a process of chunking, after which embeddings from these chunks are stored in Azure AI Search, serving as our vector database.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import os
2+
from pyngrok import ngrok, conf
3+
from dotenv import load_dotenv
4+
import subprocess
5+
6+
# Load environment variables from .env file
7+
load_dotenv()
8+
9+
# Set up Ngrok configuration
10+
ngrok_config = conf.PyngrokConfig()
11+
conf.set_default(ngrok_config)
12+
13+
# Authenticate with Ngrok using the auth token
14+
ngrok.set_auth_token(os.getenv("ngrok_key"))
15+
16+
# Create a public URL for your local Streamlit app
17+
public_url = ngrok.connect(8501)
18+
print("Ngrok Tunnel URL:", public_url)
19+
20+
# Run your Streamlit app
21+
subprocess.run(["streamlit", "run", "Demo_Suite.py"])

0 commit comments

Comments
 (0)