You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace `https://<your-foundry-resource>.services.ai.azure.com/api/projects/<your-project-name>` with the actual values from your Microsoft Foundry project.
47
44
48
45

49
46
50
47
51
-
3. **Where to find your connection string:**
48
+
3. **Where to find your endpoint:**
52
49
53
50
- Go to the **Microsoft Foundry portal**
54
51
- Navigate to your project
55
52
- Click on **Overview**
56
-
- The connection string will be displayed on the homepage of your project
53
+
- The endpoint will be displayed on the homepage of your project
print(next((item["text"]["value"] for item in first_message.content if item.get("type") =="text"), ""))
181
-
```
182
-
183
-
184
-
185
-
### Delete the Agent When Done
186
-
187
-
Once you’re finished, clean up by deleting the agent:
188
-
189
-
```python
190
-
finally:
191
-
# Clean up the agent when done
192
-
project_client.agents.delete_agent(agent.id)
193
-
print("Deleted agent")
194
-
```
195
-
196
-
Add this code to delete the agent outside of the while True-loop. Otherwise the agent will be deleted immediately after your first interaction.
197
-
198
-
199
-
200
160
## Run the Agent
201
161
202
162
Finally, run the Python script:
@@ -211,17 +171,17 @@ You can now chat with your agent directly in the terminal. Type `exit` or `quit`
211
171
212
172
If you get an error (the principal `*****-****-***-****-*****`) does **not have permission** to create assistants in your Microsoft Foundry project. Specifically, it's missing the **`Microsoft.CognitiveServices/accounts/AIServices/agents/write`** data action.
213
173
214
-
Here’s how to fix it:
174
+
Here's how to fix it:
215
175
216
176
1.**Go to the Azure Portal**: [https://portal.azure.com](https://portal.azure.com)
217
177
218
178
2.**Navigate to your Microsoft Foundry resource**:
219
179
- You can find it by searching for the name of your Foundry resource (e.g., `my-foundry-name`).
220
180
221
-
3.**Open the “Access Control (IAM)” panel**:
181
+
3.**Open the "Access Control (IAM)" panel**:
222
182
- In the left-hand menu of the resource, click **Access Control (IAM)**.
223
183
224
-
4.**Click “Add role assignment”**:
184
+
4.**Click "Add role assignment"**:
225
185
- Choose **Add → Add role assignment**
226
186
- Select a role that includes the required data action:
227
187
- Recommended: **Cognitive Services Contributor** or a **custom role** that includes `Microsoft.CognitiveServices/accounts/AIServices/agents/write`
@@ -241,15 +201,14 @@ Here’s how to fix it:
241
201
In this chapter, you have:
242
202
243
203
- Logged in to Azure
244
-
- Retrieved a connection string
204
+
- Retrieved a project endpoint
245
205
- Separated secrets from code using `.env`
246
-
- Created a basic agent with the Microsoft Foundry Agent Service
247
-
- Started a conversation with a **GPT-4o** model
248
-
- Cleaned up by deleting the agent when done
206
+
- Created a basic agent with the Foundry Agent Service
0 commit comments