Skip to content

Commit 5c1ef52

Browse files
committed
discovered method to run streamlit in Azure VM. Updated instructions with discovery. Removed Ngrok instructions
1 parent 844d217 commit 5c1ef52

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

notebooks/GenAI/embedding_demos/readme.md

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ The Azure OpenAI Demo w/ Streamlit Frontend is designed to host various demonstr
2121
- Learn the roles and functionalities of `Demo_Suite.py` and the `AI_Search_Query.py`, and `AOAI_Embeddings.py` pages.
2222
3. **Generate and Query Embeddings**:
2323
- Create and query text embeddings using the Azure OpenAI SDK.
24-
4. **Use Ngrok with Azure ML**:
25-
- Set up Ngrok to securely run the demo on Azure ML or a VM.
24+
4. **Use Azure VM (NIH only) vs VScode **:
25+
- Set up Streamlit to securely run the demo on Azure VM.
2626
5. **Setup Development Environment**:
2727
- Create a virtual environment, install dependencies, and configure environment variables.
2828
- Execute the Streamlit demo locally and in cloud environments.
@@ -92,20 +92,11 @@ In this phase, you will choose your preferred environment to execute the Azure O
9292
+ [Executing via VsCode](#executing_via_vscode)
9393

9494
### Executing via Azure ML or VM <a name="executing_via_azure_ml_vm"></a>
95-
Streamlit's native behavior expects to run applications locally on port 8501, which isn't possible when executing this demo from Azure ML or a VM. **Ngrok** is a tool that creates a secure tunnel to expose a local server to the internet. By using Ngrok, you can securely expose the Streamlit demo app running on Azure ML or a VM to the internet, bypassing the limitation of needing to run it on the local port 8501. This ensures that you can access and interact with the Streamlit application without needing to run from your local machine.
95+
If you are in the NIH environment Streamlit's native behavior expects to run applications locally on port 8501, which isn't possible when executing this demo from Azure VM.
9696

97-
**Phase 1 - Obtain a free Ngrok Authtoken:**
98-
99-
1. Visit the Ngrok website: https://ngrok.com.
100-
2. Click on the "Sign Up" button at the top right corner.
101-
3. Sign up using your email address and create a password, or use your GitHub account.
102-
4. Check your email for a verification message from Ngrok.
103-
5. Click the verification link in the email to activate your account.
104-
6. Log in to your Ngrok account.
105-
7. Once logged in, you will be taken to your dashboard.
106-
8. In your dashboard, find and copy your authentication (Authtoken) token. This token will be used for the `ngrok_key` variable in step 2.
97+
Inorder to connect to the streamlit you must change the **port to 3389**. This is an approved port and will ensure that you can access and interact with the Streamlit application without needing to run from your local machine.
10798

108-
**Phase 2 - Create a .env file:**
99+
**Phase 1 - Create a .env file:**
109100

110101
**Note:** If you have followed the steps in the [ARM Deployment tutorial](../azure_infra_setup/README.md) you have already created this file with its variables and can skip to the next section.
111102

@@ -130,7 +121,6 @@ Streamlit's native behavior expects to run applications locally on port 8501, wh
130121
AZURE_SEARCH_INDEX = "documents-index" # The index name 'documents-index' is used as default in this demo
131122
BLOB_CONTAINER_NAME = "Your Azure Blob Container name hosting files from /search_documents"
132123
BLOB_CONNECTION_STRING = "Your Azure Blob connection string"
133-
ngrok_key = "Your Ngrok Authtoken from STEP 1"
134124
```
135125
5. Save the `.env` file and exit the text editor:
136126
- Press `Ctrl + X` to exit the text editor.
@@ -141,7 +131,7 @@ Streamlit's native behavior expects to run applications locally on port 8501, wh
141131
cat .env
142132
```
143133

144-
**Phase 3 - Configure the virtual environment:**
134+
**Phase 2 - Configure the virtual environment:**
145135
1. If not already in ***/GenAI***, navigate there by:
146136
```bash
147137
cd ./notebooks/GenAI
@@ -161,17 +151,17 @@ Streamlit's native behavior expects to run applications locally on port 8501, wh
161151
pip install -r requirements.txt
162152
```
163153

164-
**Phase 4 - Execute the Streamlit demo:**
154+
**Phase 3 - Execute the Streamlit demo:**
165155
1. Navigate to the /embeddings directory (location of the Streamlit demo):
166156
```bash
167157
cd ./embedding_demos
168158
```
169159
2. Execute the Streamlit demo:
170-
- Run the [Demo_Suite_ngrok.py](./Demo_Suite_ngrok.py) file. This file will generate the secure Ngrok tunnel to access the Streamlit app. You do not need to run the `Demo_Suite.py` file.
171-
```bash
172-
python Demo_Suite_ngrok.py
160+
- Run the [Demo_Suite.py](./Demo_Suite.py) file.
161+
```sh
162+
streamlit run Demo_Suite.py --server.port 3389
173163
```
174-
***Note: Access the Streamlit site from the provided URL in the terminal.***
164+
***Note: Access the Streamlit site from the provided `External URL` in the terminal.***
175165

176166
![Image](https://github.com/user-attachments/assets/663053ed-957f-4ec3-b8b1-340b820852cc)
177167

@@ -234,7 +224,7 @@ To excute this demo, be sure to complete the following steps:
234224
```
235225

236226
## Conclusion <a name="conclusion"></a>
237-
By completing the "Azure OpenAI Demo w/ Streamlit Frontend" tutorial, you have gained valuable hands-on experience in integrating Azure OpenAI services with a Streamlit frontend. You have learned how to set up and configure essential components, including Azure OpenAI, Azure AI Search, and Azure Blob Storage. Additionally, you have explored the functionalities of key scripts and understood how to generate and query embeddings for interactive applications. This tutorial also guided you through executing the demo both on Azure ML using Ngrok and locally using VSCode, ensuring you are equipped to handle different deployment scenarios. We hope this tutorial has been informative and empowers you to leverage Azure OpenAI and Streamlit for your future projects.
227+
By completing the "Azure OpenAI Demo w/ Streamlit Frontend" tutorial, you have gained valuable hands-on experience in integrating Azure OpenAI services with a Streamlit frontend. You have learned how to set up and configure essential components, including Azure OpenAI, Azure AI Search, and Azure Blob Storage. Additionally, you have explored the functionalities of key scripts and understood how to generate and query embeddings for interactive applications. This tutorial also guided you through executing the demo both on Azure VM and locally using VSCode, ensuring you are equipped to handle different deployment scenarios. We hope this tutorial has been informative and empowers you to leverage Azure OpenAI and Streamlit for your future projects.
238228

239229
## Clean Up <a name="clean_up"></a>
240230
Make sure to shut down your Azure ML compute and if desired you can delete your Azure AI Search service, Azure Blob Storage Account, and Azure OpenAI service. ***Note these services can be used in other tutorials in this notebook.***

0 commit comments

Comments
 (0)