Skip to content

Commit a765454

Browse files
chore: Add Visual Studio Code Web Support
2 parents 83b2e98 + e0810c0 commit a765454

17 files changed

+453
-12
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ For additional documentation of the default enabled services of this solution ac
8585
QUICK DEPLOY
8686
</h2>
8787

88-
| [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/microsoft/Deploy-Your-AI-Application-In-Production) | [![Open in Dev Containers](https://img.shields.io/static/v1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/microsoft/Deploy-Your-AI-Application-In-Production) |
89-
|---|---|
90-
[Steps to deploy with GitHub Codespaces](docs/github_code_spaces_steps.md)| [Steps to deploy with Dev Container](docs/Dev_ContainerSteps.md)
88+
| [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/microsoft/Deploy-Your-AI-Application-In-Production) | [![Open in Dev Containers](https://img.shields.io/static/v1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/microsoft/Deploy-Your-AI-Application-In-Production) | [![Open in Visual Studio Code Web](https://img.shields.io/static/v1?style=for-the-badge&label=Visual%20Studio%20Code%20(Web)&message=Open&color=blue&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/azure/?vscode-azure-exp=foundry&agentPayload=eyJiYXNlVXJsIjogImh0dHBzOi8vcmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbS9taWNyb3NvZnQvRGVwbG95LVlvdXItQUktQXBwbGljYXRpb24tSW4tUHJvZHVjdGlvbi9yZWZzL2hlYWRzL21haW4vaW5mcmEvdnNjb2RlX3dlYiIsICJpbmRleFVybCI6ICIvaW5kZXguanNvbiIsICJ2YXJpYWJsZXMiOiB7ImFnZW50SWQiOiAiIiwgImNvbm5lY3Rpb25TdHJpbmciOiAiIiwgInRocmVhZElkIjogIiIsICJ1c2VyTWVzc2FnZSI6ICIiLCAicGxheWdyb3VuZE5hbWUiOiAiIiwgImxvY2F0aW9uIjogIiIsICJzdWJzY3JpcHRpb25JZCI6ICIiLCAicmVzb3VyY2VJZCI6ICIiLCAicHJvamVjdFJlc291cmNlSWQiOiAiIiwgImVuZHBvaW50IjogIiJ9LCAiY29kZVJvdXRlIjogWyJhaS1wcm9qZWN0cy1zZGsiLCAicHl0aG9uIiwgImRlZmF1bHQtYXp1cmUtYXV0aCIsICJlbmRwb2ludCJdfQ==) |
89+
|---|---|---|
90+
[Steps to deploy with GitHub Codespaces](docs/github_code_spaces_steps.md)| [Steps to deploy with Dev Container](docs/Dev_ContainerSteps.md) | [Steps to deploy with VS Code Web](docs/vscode_web_steps.md) |
9191

9292

9393
## Connect to and validate access to the new environment

azure.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ hooks:
1515
continueOnError: false
1616
posix:
1717
shell: sh
18-
run: sudo chmod u+r+x ./scripts/set_conns_env_vars.sh; sudo ./scripts/set_conns_env_vars.sh
18+
run: bash ./scripts/set_conns_env_vars.sh
1919
interactive: true
2020
continueOnError: false
2121
preprovision:
2222
posix:
2323
shell: sh
24-
run: sudo chmod u+r+x ./scripts/auth_init.sh; sudo ./scripts/auth_init.sh
24+
run: bash ./scripts/auth_init.sh
2525
interactive: true
2626
continueOnError: false
2727
windows:
@@ -32,7 +32,7 @@ hooks:
3232
postprovision:
3333
posix:
3434
shell: sh
35-
run: sudo chmod u+r+x ./scripts/process_sample_data.sh; sudo chmod u+r+x ./scripts/postprovision.sh; sudo ./scripts/postprovision.sh
35+
run: bash ./scripts/postprovision.sh
3636
interactive: true
3737
continueOnError: false
3838
windows:

docs/vscode_web_steps.md

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
### VS Code Web
2+
3+
You can run this solution using VS Code Web. The button will open a web-based VS Code instance in your browser:
4+
5+
1. Open the project:
6+
7+
[![Open in Visual Studio Code Web](https://img.shields.io/static/v1?style=for-the-badge&label=Visual%20Studio%20Code%20(Web)&message=Open&color=blue&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/azure/?vscode-azure-exp=foundry&agentPayload=eyJiYXNlVXJsIjogImh0dHBzOi8vcmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbS9taWNyb3NvZnQvRGVwbG95LVlvdXItQUktQXBwbGljYXRpb24tSW4tUHJvZHVjdGlvbi9yZWZzL2hlYWRzL21haW4vaW5mcmEvdnNjb2RlX3dlYiIsICJpbmRleFVybCI6ICIvaW5kZXguanNvbiIsICJ2YXJpYWJsZXMiOiB7ImFnZW50SWQiOiAiIiwgImNvbm5lY3Rpb25TdHJpbmciOiAiIiwgInRocmVhZElkIjogIiIsICJ1c2VyTWVzc2FnZSI6ICIiLCAicGxheWdyb3VuZE5hbWUiOiAiIiwgImxvY2F0aW9uIjogIiIsICJzdWJzY3JpcHRpb25JZCI6ICIiLCAicmVzb3VyY2VJZCI6ICIiLCAicHJvamVjdFJlc291cmNlSWQiOiAiIiwgImVuZHBvaW50IjogIiJ9LCAiY29kZVJvdXRlIjogWyJhaS1wcm9qZWN0cy1zZGsiLCAicHl0aG9uIiwgImRlZmF1bHQtYXp1cmUtYXV0aCIsICJlbmRwb2ludCJdfQ==)
8+
9+
3. VS Code Web window will open (may take a few minutes to load), Sign in with your Azure account when prompted.
10+
4. Select the subscription where you want to deploy the solution
11+
5. Wait for the environment to initialize (includes all deployment tools)
12+
6. Once the solution opens, the **AI Foundry terminal** will automatically start running the following command to install the required dependencies:
13+
14+
```shell
15+
sh install.sh
16+
```
17+
During this process, you’ll be prompted with the message:
18+
```
19+
What would you like to do with these files?
20+
- Overwrite with versions from template
21+
- Keep my existing files unchanged
22+
```
23+
Choose “**Overwrite with versions from template**” and provide a unique environment name when prompted.
24+
5. Continue with the [deploying steps](#steps-to-provision-network-isolated-environment-using-dev-container).
25+
26+
# Steps to Provision Network Isolated environment using Dev Container
27+
28+
1. Log into your Azure subscription:
29+
30+
```shell
31+
azd auth login
32+
```
33+
34+
![Image showing the entering of the command 'azd auth' in the terminal of VS Code](../img/provisioning/azdauthcommandline.png)
35+
36+
![image showing the authorization window opening in the browser](../img/provisioning/azdauthpopup.png)
37+
38+
![Image showing the password prompt for azure](../img/provisioning/enterpassword.png)
39+
40+
2. Login to azure, run the below command:
41+
```shell
42+
az login --use-device-code
43+
```
44+
The [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/what-is-azure-cli?view=azure-cli-latest) is used by scripts that run during deployment. This will prompt you to select a subscription. Please select the appropriate subscription.
45+
46+
![image showing theaz login in the vs code terminal](../img/provisioning/az_login.png)
47+
48+
3. Now start the deployment of the infrastructure by typing the below command:
49+
```shell
50+
azd up
51+
```
52+
> ⚠️ **Note:** The latest version of the Azure Developer CLI (AZD) is currently limited on prompting for missing parameters. The feature flag parameters in this solution have been temporarily defaulted to `'disabled'` until this limitation is lifted and prompting will resume.
53+
54+
55+
![image showing the terminal in vs code](images/re_use_log/nonwaf.png)
56+
57+
It will prompt you for the region to deploy the resources into as well as any additional Azure resources to be provisioned and configured.
58+
59+
**Important:** Be sure to remember the vm password. This will be used in a later step. You are still required to log into Azure once you connect through the virtual machine.
60+
> ⚠️ **Note:**
61+
> 1. For **WAF Deployment**, Select the **Network Isolation** as **'True'**.
62+
> ![alt text](images/re_use_log/waf.png)
63+
> 2. For **Sample App Deployment**, Select the **appSampleEnabled** as **'True'**.
64+
> ![alt text](images/re_use_log/samapp.png)
65+
66+
4. After completeing the required paramters that you were prompted for, the provisioning of resources will run and deploy the Network Isolated AI Foundry development portal and dependent resources in about 20-30 minutes.
67+
68+
69+
# Post Deployment Steps:
70+
These steps will help to check that the isolated environment was set up correctly.
71+
Follow these steps to check the creation of the required private endpoints in the environment (when set to networkIsolation = true).
72+
73+
One way to verify whether access is private to the foundry is by launching Azure AI Foundry from the portal.
74+
75+
![Image showing if network isolation is checked](images/re_use_log/AI_Foundry_Portal.png)
76+
77+
When a user that is not connected through the virtual network via an RDP approved connection will see the following screen in their browser. This is the intended behavior!
78+
79+
![Image showing the virtual machine in the browser](images/re_use_log/AI_Foundry_view.png)
80+
81+
A more thourough check is to look for the networking settings and checking for private end points.
82+
83+
1. Go to the Azure Portal and select your Azure AI hub that was just created.
84+
85+
2. Click on Resource Management and then Networking.
86+
87+
![Image showing the Azure Portal for AI Foundry Hub and the settings blade](images/re_use_log/Private_network_endpoints.png)
88+
89+
90+
Here, you will find the private endpoints that are connected to the resources within the foundry managed virtual network. Ensure that these private endpoints are active.
91+
The foundry should show that Public access is ‘disabled’.
92+
93+
## Connecting to the isolated network via RDP
94+
1. Navigate to the resource group where the isolated AI Foundry was deployed to and select the virtual machine.
95+
96+
![Image showing the Azure Portal for the virtual machine](../img/provisioning/checkNetworkIsolation5.png)
97+
98+
2. Be sure that the Virtual Machine is running. If not, start the VM.
99+
100+
![Image showing the Azure Portal VM and the start/stop button](../img/provisioning/checkNetworkIsolation6.png)
101+
102+
3. Select “Bastion” under the ‘Connect’ heading in the VM resource.
103+
104+
![Image showing the bastion blade selected](../img/provisioning/checkNetworkIsolation7.png)
105+
106+
4. Supply the username and the password you created as environment variables and press the connect button.
107+
108+
![Image showing the screen to enter the VM Admin info and the connect to bastion button](../img/provisioning/Bastion.png)
109+
110+
5. Your virtual machine will launch and you will see a different screen.
111+
112+
![Image showing the opening of the Virtual machine in another browser tab](../img/provisioning/checkNetworkIsolation9.png)
113+
114+
6. Launch Edge browser and navigate to your Azure AI Foundry. https://ai.azure.com Sign in using your credentials.
115+
116+
117+
7. You are challenged by MFA to connect.
118+
119+
![Image showing the Multi Factor Authentication popup](../img/provisioning/checkNetworkIsolation10.png)
120+
121+
8. You will now be able to view the Azure AI Foundry which is contained in an isolated network.
122+
123+
![Image showing the Azure Foundry AI Hub with a private bubble icon](images/re_use_log/Azure_ai_foundry_inside_vm.png)
124+
125+
## Contributing
126+
127+
This project welcomes contributions and suggestions. Most contributions require you to agree to a
128+
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
129+
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
130+
131+
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
132+
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
133+
provided by the bot. You will only need to do this once across all repos using our CLA.
134+
135+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
136+
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
137+
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
138+
139+
## Trademarks
140+
141+
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
142+
trademarks or logos is subject to and must follow
143+
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
144+
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
145+
Any use of third-party trademarks or logos are subject to those third-party's policies.

infra/vscode_web/.env

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
AZURE_EXISTING_AGENT_ID="<%= agentId %>"
2+
AZURE_ENV_NAME="<%= playgroundName %>"
3+
# AZURE_LOCATION="<%= location %>"
4+
AZURE_SUBSCRIPTION_ID="<%= subscriptionId %>"
5+
AZURE_EXISTING_AIPROJECT_ENDPOINT="<%= endpoint %>"
6+
AZURE_EXISTING_AIPROJECT_RESOURCE_ID="<%= projectResourceId %>"
7+
AZD_ALLOW_NON_EMPTY_FOLDER=true

infra/vscode_web/.gitignore

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# ========== .NET ========== #
2+
## Build results
3+
bin/
4+
obj/
5+
[Bb]uild/
6+
[Ll]ogs/
7+
*.log
8+
## User-specific files
9+
*.user
10+
*.suo
11+
*.userosscache
12+
*.sln.docstates
13+
*.vsp
14+
*.vspx
15+
*.vspscc
16+
## Rider / VS Code / Visual Studio
17+
.idea/
18+
.vscode/
19+
.vs/
20+
## NuGet packages
21+
*.nupkg
22+
packages/
23+
*.snupkg
24+
project.lock.json
25+
project.assets.json
26+
## Dotnet tools
27+
.tools/
28+
# ========== Java ========== #
29+
## Compiled class files
30+
*.class
31+
## Logs
32+
*.log
33+
## Maven
34+
target/
35+
## Gradle
36+
.gradle/
37+
build/
38+
## Eclipse
39+
.project
40+
.classpath
41+
.settings/
42+
.loadpath
43+
## IntelliJ IDEA
44+
*.iml
45+
*.ipr
46+
*.iws
47+
out/
48+
.idea/
49+
# ========== Python ========== #
50+
## Byte-compiled / cache
51+
__pycache__/
52+
*.py[cod]
53+
*$py.class
54+
## Virtual environment
55+
env/
56+
venv/
57+
ENV/
58+
.venv/
59+
.env*
60+
## PyInstaller
61+
*.spec
62+
dist/
63+
build/
64+
## Jupyter Notebook
65+
.ipynb_checkpoints/
66+
## Misc
67+
*.log
68+
*.pot
69+
*.pyc
70+
.DS_Store
71+
*.sqlite3
72+
# ========== General ========== #
73+
## OS generated
74+
Thumbs.db
75+
ehthumbs.db
76+
Desktop.ini
77+
.DS_Store
78+
*.swp
79+
*.swo
80+
*.bak
81+
*.tmp
82+
*.old
83+
## Node (just in case mixed project)
84+
node_modules/
85+
# End

infra/vscode_web/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Microsoft Corporation.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

infra/vscode_web/README-noazd.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# VS Code for the Web - Azure AI Foundry Templates
2+

infra/vscode_web/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# VS Code for the Web - Azure AI Foundry Templates
2+
3+
We've generated a simple development environment for you to deploy the templates.
4+
5+
The Azure AI Foundry extension provides tools to help you build, test, and deploy AI models and AI Applications directly from VS Code. It offers simplified operations for interacting with your models, agents, and threads without leaving your development environment. Click on the Azure AI Foundry Icon on the left to see more.
6+
7+
Follow the instructions below to get started!
8+
9+
You should see a terminal opened with the template code already cloned.
10+
11+
## Deploy the template
12+
13+
You can provision and deploy this template using:
14+
15+
```bash
16+
azd up
17+
```
18+
19+
Follow any instructions from the deployment script and launch the application.
20+
21+
22+
If you need to delete the deployment and stop incurring any charges, run:
23+
24+
```bash
25+
azd down
26+
```
27+
28+
## Continuing on your local desktop
29+
30+
You can keep working locally on VS Code Desktop by clicking "Continue On Desktop..." at the bottom left of this screen. Be sure to take the .env file with you using these steps:
31+
32+
- Right-click the .env file
33+
- Select "Download"
34+
- Move the file from your Downloads folder to the local git repo directory
35+
- For Windows, you will need to rename the file back to .env using right-click "Rename..."
36+
37+
## More examples
38+
39+
Check out [Azure AI Projects client library for Python](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/ai/azure-ai-projects/README.md) for more information on using this SDK.
40+
41+
## Troubleshooting
42+
43+
- If you are instantiating your client via endpoint on an Azure AI Foundry project, ensure the endpoint is set in the `.env` as https://{your-foundry-resource-name}.services.ai.azure.com/api/projects/{your-foundry-project-name}`

infra/vscode_web/codeSample.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from azure.ai.projects import AIProjectClient
2+
from azure.identity import DefaultAzureCredential
3+
4+
project_client = AIProjectClient.from_connection_string(
5+
credential=DefaultAzureCredential(),
6+
conn_str="<%= connectionString %>")
7+
8+
agent = project_client.agents.get_agent("<%= agentId %>")
9+
10+
thread = project_client.agents.create_thread()
11+
print(f"Created thread, ID: {thread.id}")
12+
13+
message = project_client.agents.create_message(
14+
thread_id=thread.id,
15+
role="user",
16+
content="<%= userMessage %>"
17+
)
18+
19+
run = project_client.agents.create_and_process_run(
20+
thread_id=thread.id,
21+
agent_id=agent.id)
22+
messages = project_client.agents.list_messages(thread_id=thread.id)
23+
24+
for text_message in messages.text_messages:
25+
print(text_message.as_dict())
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
azure-ai-projects==1.0.0b12
2+
azure-identity==1.20.0
3+
ansible-core~=2.17.0

0 commit comments

Comments
 (0)