Skip to content

Commit 7264822

Browse files
DevConatiner Implemention for MACAE
1 parent e5f0981 commit 7264822

File tree

3 files changed

+174
-0
lines changed

3 files changed

+174
-0
lines changed

.devcontainer/devcontainer.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "Multi Agent Custom Automation Engine Solution Accelerator",
3+
"image": "mcr.microsoft.com/devcontainers/python:3.10",
4+
"features": {
5+
"ghcr.io/devcontainers/features/azure-cli:1.0.8": {},
6+
"ghcr.io/azure/azure-dev/azd:latest": {},
7+
"ghcr.io/rchaganti/vsc-devcontainer-features/azurebicep:1.0.5": {}
8+
},
9+
10+
"postCreateCommand": "sudo chmod +x .devcontainer/setupEnv.sh && ./.devcontainer/setupEnv.sh",
11+
12+
"customizations": {
13+
"vscode": {
14+
"extensions": [
15+
"ms-azuretools.azure-dev",
16+
"ms-azuretools.vscode-bicep",
17+
"ms-python.python"
18+
]
19+
},
20+
"codespaces": {
21+
"openFiles": [
22+
"README.md"
23+
]
24+
}
25+
},
26+
"forwardPorts": [
27+
8000,
28+
3000
29+
],
30+
"remoteUser": "vscode",
31+
"hostRequirements": {
32+
"memory": "8gb"
33+
}
34+
}

.devcontainer/setupEnv.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
pip install --upgrade pip
4+
5+
6+
(cd ./src/frontend; pip install -r requirements.txt)
7+
8+
(cd ./src/backend; pip install -r requirements.txt)

documentation/LOCAL_DEPLOYMENT.md

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Guide to local development
2+
3+
## Requirements:
4+
5+
- Python 3.10 or higher + PIP
6+
- Azure CLI, and an Azure Subscription
7+
- Visual Studio Code IDE
8+
9+
10+
1. Start Docker Desktop (install it if not already installed)
11+
1. Open the project:
12+
[![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/Multi-Agent-Custom-Automation-Engine-Solution-Accelerator)
13+
1. In the VS Code window that opens, once the project files show up (this may take several minutes), open a terminal window
14+
15+
## Local deployment and debugging:
16+
17+
1. **Clone the repository.**
18+
19+
2. **Log into the Azure CLI:**
20+
21+
- Check your login status using:
22+
```bash
23+
az account show
24+
```
25+
- If not logged in, use:
26+
```bash
27+
az login
28+
```
29+
- To specify a tenant, use:
30+
```bash
31+
az login --tenant <tenant_id>
32+
```
33+
34+
3. **Create a Resource Group:**
35+
36+
- You can create it either through the Azure Portal or the Azure CLI:
37+
```bash
38+
az group create --name <resource-group-name> --location EastUS2
39+
```
40+
41+
4. **Deploy the Bicep template:**
42+
43+
- You can use the Bicep extension for VSCode (Right-click the `.bicep` file, then select "Show deployment plane") or use the Azure CLI:
44+
```bash
45+
az deployment group create -g <resource-group-name> -f deploy/macae-dev.bicep --query 'properties.outputs'
46+
```
47+
- **Note**: You will be prompted for a `principalId`, which is the ObjectID of your user in Entra ID. To find it, use the Azure Portal or run:
48+
```bash
49+
az ad signed-in-user show --query id -o tsv
50+
```
51+
You will also be prompted for locations for Cosmos and Open AI services. This is to allow separate regions where there may be service quota restrictions.
52+
53+
- **Additional Notes**:
54+
55+
**Role Assignments in Bicep Deployment:**
56+
57+
The **macae-dev.bicep** deployment includes the assignment of the appropriate roles to AOAI and Cosmos services. If you want to modify an existing implementation—for example, to use resources deployed as part of the simple deployment for local debugging—you will need to add your own credentials to access the Cosmos and AOAI services. You can add these permissions using the following commands:
58+
```bash
59+
az cosmosdb sql role assignment create --resource-group <solution-accelerator-rg> --account-name <cosmos-db-account-name> --role-definition-name "Cosmos DB Built-in Data Contributor" --principal-id <aad-user-object-id> --scope /subscriptions/<subscription-id>/resourceGroups/<solution-accelerator-rg>/providers/Microsoft.DocumentDB/databaseAccounts/<cosmos-db-account-name>
60+
```
61+
62+
```bash
63+
az role assignment create --assignee <aad-user-upn> --role "Cognitive Services OpenAI User" --scope /subscriptions/<subscription-id>/resourceGroups/<solution-accelerator-rg>/providers/Microsoft.CognitiveServices/accounts/<azure-openai-account-name>
64+
```
65+
**Using a Different Database in Cosmos:**
66+
67+
You can set the solution up to use a different database in Cosmos. For example, you can name it something like autogen-dev. To do this:
68+
1. Change the environment variable **COSMOSDB_DATABASE** to the new database name.
69+
2. You will need to create the database in the Cosmos DB account. You can do this from the Data Explorer pane in the portal, click on the drop down labeled “_+ New Container_” and provide all the necessary details.
70+
71+
6. **Create a `.env` file:**
72+
73+
- Navigate to the `src` folder and create a `.env` file based on the provided `.env.sample` file.
74+
75+
7. **Fill in the `.env` file:**
76+
77+
- Use the output from the deployment or check the Azure Portal under "Deployments" in the resource group.
78+
79+
8. **(Optional) Set up a virtual environment:**
80+
81+
- If you are using `venv`, create and activate your virtual environment for both the frontend and backend folders.
82+
83+
9. **Install requirements - frontend:**
84+
85+
- In each of the frontend and backend folders -
86+
Open a terminal in the `src` folder and run:
87+
```bash
88+
pip install -r requirements.txt
89+
```
90+
91+
10. **Run the application:**
92+
- From the src/backend directory:
93+
```bash
94+
python app.py
95+
```
96+
- In a new terminal from the src/frontend directory
97+
```bash
98+
python frontend_server.py
99+
```
100+
101+
10. Open a browser and navigate to `http://localhost:3000`
102+
11. To see swagger API documentation, you can navigate to `http://localhost:8000/docs`
103+
104+
## Debugging the solution locally
105+
106+
You can debug the API backend running locally with VSCode using the following launch.json entry:
107+
108+
```
109+
{
110+
"name": "Python Debugger: Backend",
111+
"type": "debugpy",
112+
"request": "launch",
113+
"cwd": "${workspaceFolder}/src/backend",
114+
"module": "uvicorn",
115+
"args": ["app:app", "--reload"],
116+
"jinja": true
117+
}
118+
```
119+
To debug the python server in the frontend directory (frontend_server.py) and related, add the following launch.json entry:
120+
121+
```
122+
{
123+
"name": "Python Debugger: Frontend",
124+
"type": "debugpy",
125+
"request": "launch",
126+
"cwd": "${workspaceFolder}/src/frontend",
127+
"module": "uvicorn",
128+
"args": ["frontend_server:app", "--port", "3000", "--reload"],
129+
"jinja": true
130+
}
131+
```
132+

0 commit comments

Comments
 (0)