Skip to content

Commit 2b66e69

Browse files
authored
Merge pull request #128 from microsoft/azd-to-main
Azd to main
2 parents a762365 + 82fff2d commit 2b66e69

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+6131
-107
lines changed

README.md

Lines changed: 154 additions & 107 deletions
Large diffs are not rendered by default.

azure.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json
2+
name: multi-agent-custom-automation-engine-solution-accelerator
3+

docs/CustomizeSolution.md

Lines changed: 618 additions & 0 deletions
Large diffs are not rendered by default.

docs/LocalDeployment.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
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+
# Local setup
10+
11+
> **Note for macOS Developers**: If you are using macOS on Apple Silicon (ARM64) the DevContainer will **not** work. This is due to a limitation with the Azure Functions Core Tools (see [here](https://github.com/Azure/azure-functions-core-tools/issues/3112)). We recommend using the [Non DevContainer Setup](./NON_DEVCONTAINER_SETUP.md) instructions to run the accelerator locally.
12+
13+
The easiest way to run this accelerator is in a VS Code Dev Containers, which will open the project in your local VS Code using the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers):
14+
15+
1. Start Docker Desktop (install it if not already installed)
16+
1. Open the project:
17+
[![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)
18+
19+
1. In the VS Code window that opens, once the project files show up (this may take several minutes), open a terminal window
20+
21+
## Detailed Development Container setup instructions
22+
23+
The solution contains a [development container](https://code.visualstudio.com/docs/remote/containers) with all the required tooling to develop and deploy the accelerator. To deploy the Chat With Your Data accelerator using the provided development container you will also need:
24+
25+
* [Visual Studio Code](https://code.visualstudio.com)
26+
* [Remote containers extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
27+
28+
If you are running this on Windows, we recommend you clone this repository in [WSL](https://code.visualstudio.com/docs/remote/wsl)
29+
30+
```cmd
31+
git clone https://github.com/microsoft/Multi-Agent-Custom-Automation-Engine-Solution-Accelerator
32+
```
33+
34+
Open the cloned repository in Visual Studio Code and connect to the development container.
35+
36+
```cmd
37+
code .
38+
```
39+
40+
!!! tip
41+
Visual Studio Code should recognize the available development container and ask you to open the folder using it. For additional details on connecting to remote containers, please see the [Open an existing folder in a container](https://code.visualstudio.com/docs/remote/containers#_quick-start-open-an-existing-folder-in-a-container) quickstart.
42+
43+
When you start the development container for the first time, the container will be built. This usually takes a few minutes. **Please use the development container for all further steps.**
44+
45+
The files for the dev container are located in `/.devcontainer/` folder.
46+
47+
## Local deployment and debugging:
48+
49+
1. **Clone the repository.**
50+
51+
2. **Log into the Azure CLI:**
52+
53+
- Check your login status using:
54+
```bash
55+
az account show
56+
```
57+
- If not logged in, use:
58+
```bash
59+
az login
60+
```
61+
- To specify a tenant, use:
62+
```bash
63+
az login --tenant <tenant_id>
64+
```
65+
66+
3. **Create a Resource Group:**
67+
68+
- You can create it either through the Azure Portal or the Azure CLI:
69+
```bash
70+
az group create --name <resource-group-name> --location EastUS2
71+
```
72+
73+
4. **Deploy the Bicep template:**
74+
75+
- You can use the Bicep extension for VSCode (Right-click the `.bicep` file, then select "Show deployment plane") or use the Azure CLI:
76+
```bash
77+
az deployment group create -g <resource-group-name> -f deploy/macae-dev.bicep --query 'properties.outputs'
78+
```
79+
- **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:
80+
```bash
81+
az ad signed-in-user show --query id -o tsv
82+
```
83+
You will also be prompted for locations for Cosmos and OpenAI services. This is to allow separate regions where there may be service quota restrictions.
84+
85+
- **Additional Notes**:
86+
87+
**Role Assignments in Bicep Deployment:**
88+
89+
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:
90+
```bash
91+
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>
92+
```
93+
94+
```bash
95+
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>
96+
```
97+
**Using a Different Database in Cosmos:**
98+
99+
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:
100+
1. Change the environment variable **COSMOSDB_DATABASE** to the new database name.
101+
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.
102+
103+
6. **Create a `.env` file:**
104+
105+
- Navigate to the `src` folder and create a `.env` file based on the provided `.env.sample` file.
106+
107+
7. **Fill in the `.env` file:**
108+
109+
- Use the output from the deployment or check the Azure Portal under "Deployments" in the resource group.
110+
111+
8. **(Optional) Set up a virtual environment:**
112+
113+
- If you are using `venv`, create and activate your virtual environment for both the frontend and backend folders.
114+
115+
9. **Install requirements - frontend:**
116+
117+
- In each of the frontend and backend folders -
118+
Open a terminal in the `src` folder and run:
119+
```bash
120+
pip install -r requirements.txt
121+
```
122+
123+
10. **Run the application:**
124+
- From the src/backend directory:
125+
```bash
126+
python app.py
127+
```
128+
- In a new terminal from the src/frontend directory
129+
```bash
130+
python frontend_server.py
131+
```
132+
133+
10. Open a browser and navigate to `http://localhost:3000`
134+
11. To see swagger API documentation, you can navigate to `http://localhost:8000/docs`
135+
136+
## Debugging the solution locally
137+
138+
You can debug the API backend running locally with VSCode using the following launch.json entry:
139+
140+
```
141+
{
142+
"name": "Python Debugger: Backend",
143+
"type": "debugpy",
144+
"request": "launch",
145+
"cwd": "${workspaceFolder}/src/backend",
146+
"module": "uvicorn",
147+
"args": ["app:app", "--reload"],
148+
"jinja": true
149+
}
150+
```
151+
To debug the python server in the frontend directory (frontend_server.py) and related, add the following launch.json entry:
152+
153+
```
154+
{
155+
"name": "Python Debugger: Frontend",
156+
"type": "debugpy",
157+
"request": "launch",
158+
"cwd": "${workspaceFolder}/src/frontend",
159+
"module": "uvicorn",
160+
"args": ["frontend_server:app", "--port", "3000", "--reload"],
161+
"jinja": true
162+
}
163+
```
164+
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Set Up Authentication in Azure App Service
2+
3+
## Step 1: Add Authentication in Azure App Service configuration
4+
5+
1. Click on `Authentication` from left menu.
6+
7+
![Authentication](./images/azure-app-service-auth-setup/AppAuthentication.png)
8+
9+
2. Click on `+ Add Provider` to see a list of identity providers.
10+
11+
![Authentication Identity](./images/azure-app-service-auth-setup/AppAuthenticationIdentity.png)
12+
13+
3. Click on `+ Add Provider` to see a list of identity providers.
14+
15+
![Add Provider](./images/azure-app-service-auth-setup/AppAuthIdentityProvider.png)
16+
17+
4. Select the first option `Microsoft Entra Id` from the drop-down list. If `Create new app registration` is disabled, go to [Step 1a](#step-1a-creating-a-new-app-registration).
18+
19+
![Add Provider](./images/azure-app-service-auth-setup/AppAuthIdentityProviderAdd.png)
20+
21+
5. Accept the default values and click on `Add` button to go back to the previous page with the idenity provider added.
22+
23+
![Add Provider](./images/azure-app-service-auth-setup/AppAuthIdentityProviderAdded.png)
24+
25+
### Step 1a: Creating a new App Registration
26+
27+
1. Click on `Home` and select `Microsoft Entra ID`.
28+
29+
![Microsoft Entra ID](./images/azure-app-service-auth-setup/MicrosoftEntraID.png)
30+
31+
2. Click on `App registrations`.
32+
33+
![App registrations](./images/azure-app-service-auth-setup/Appregistrations.png)
34+
35+
3. Click on `+ New registration`.
36+
37+
![New Registrations](./images/azure-app-service-auth-setup/NewRegistration.png)
38+
39+
4. Provide the `Name`, select supported account types as `Accounts in this organizational directory only(Contoso only - Single tenant)`, select platform as `Web`, enter/select the `URL` and register.
40+
41+
![Add Details](./images/azure-app-service-auth-setup/AddDetails.png)
42+
43+
5. After application is created sucessfully, then click on `Add a Redirect URL`.
44+
45+
![Redirect URL](./images/azure-app-service-auth-setup/AddRedirectURL.png)
46+
47+
6. Click on `+ Add a platform`.
48+
49+
![+ Add platform](./images/azure-app-service-auth-setup/AddPlatform.png)
50+
51+
7. Click on `Web`.
52+
53+
![Web](./images/azure-app-service-auth-setup/Web.png)
54+
55+
8. Enter the `web app URL` (Provide the app service name in place of XXXX) and Save. Then go back to [Step 1](#step-1-add-authentication-in-azure-app-service-configuration) and follow from _Point 4_ choose `Pick an existing app registration in this directory` from the Add an Identity Provider page and provide the newly registered App Name.
56+
E.g. https://appservicename.azurewebsites.net/.auth/login/aad/callback
57+
58+
![Add Details](./images/azure-app-service-auth-setup/WebAppURL.png)
350 KB
Loading
194 KB
Loading
41.6 KB
Loading
129 KB
Loading
206 KB
Loading

0 commit comments

Comments
 (0)