Skip to content

Commit 8ebc53c

Browse files
authored
Update capability-hosts.md
1 parent 0ad7938 commit 8ebc53c

File tree

1 file changed

+59
-121
lines changed

1 file changed

+59
-121
lines changed

articles/ai-foundry/agents/concepts/capability-hosts.md

Lines changed: 59 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -50,57 +50,14 @@ Capability hosts follow a hierarchy where more specific configurations override
5050
2. **Account-level capability host** - Provides shared defaults for all projects under the account.
5151
3. **Project-level capability host** - Overrides account-level and service defaults for that specific project.
5252

53-
## Avoiding HTTP 409 (Conflict) errors
54-
55-
### Understanding capability host constraints
53+
## Understanding capability host constraints
5654

5755
When creating capability hosts, be aware of these important constraints to avoid conflicts:
5856

59-
> [!IMPORTANT]
60-
> **One capability host per scope**: Each account and each project can only have one active capability host. Attempting to create a second capability host with a different name at the same scope will result in a 409 conflict.
61-
62-
### Best practices to prevent conflicts
63-
64-
#### 1. **Pre-request validation**
65-
Always check for existing capability hosts before attempting to create new ones:
66-
67-
**For account-level capability hosts:**
68-
```http
69-
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/capabilityHosts?api-version=2025-06-01
70-
```
71-
72-
#### 2. **Monitor long-running operations**
73-
Capability host operations are asynchronous. Always monitor operation status:
74-
75-
```http
76-
GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/operationResults/{operationId}?api-version=2025-06-01
77-
```
78-
79-
#### 4. **Handle idempotent requests correctly**
80-
The system supports idempotent create requests:
81-
- **Same name + same configuration** = Returns existing resource (success)
82-
- **Same name + different configuration** = Returns 400 Bad Request
83-
- **Different name** = Returns 409 Conflict
57+
- **One capability host per scope**: Each account and each project can only have one active capability host. Attempting to create a second capability host with a different name at the same scope will result in a 409 conflict.
8458

85-
### Configuration update limitations
59+
- **Configuration updates are not supported**: If you need to change configuration, you must delete the existing capability host and recreate it.
8660

87-
> [!WARNING]
88-
> Configuration updates are not supported. If you need to change configuration, you must delete the existing capability host and recreate it.
89-
90-
**Error example:**
91-
```json
92-
{
93-
"error": {
94-
"code": "InvalidData",
95-
"message": "Update of capability is not currently supported. Please delete and recreate with the new configuration."
96-
}
97-
}
98-
```
99-
100-
**Recommended approach for configuration changes:**
101-
1. Delete the existing capability host
102-
2. Wait for deletion to complete
103-
3. Create a new capability host with the desired configuration
10461

10562
## Recommended setup
10663

@@ -120,9 +77,7 @@ A capability host must be configured with the following three properties at eith
12077
|----------|---------|------------------------|-------------|
12178
| `aiServicesConnections` | Use your own model deployments | Azure OpenAI | When you want to use models from your existing Azure OpenAI resource instead of the built-in account level ones. |
12279

123-
### Account capability host
124-
Create an account-level capability host that provides shared defaults:
125-
80+
**Account capability host**
12681
```http
12782
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/capabilityHosts/{name}?api-version=2025-06-01
12883
@@ -150,18 +105,6 @@ PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{
150105
}
151106
```
152107

153-
### Example URLs from your environment:
154-
155-
**Account-level capability host:**
156-
```
157-
https://management.azure.com/subscriptions/b17253fa-f327-42d6-9686-f3e553e24763/resourceGroups/howie-cap-1/providers/Microsoft.CognitiveServices/accounts/foundyav3b/capabilityHosts/caphostaccount?api-version=2025-06-01
158-
```
159-
160-
**Project-level capability host:**
161-
```
162-
https://management.azure.com/subscriptions/b17253fa-f327-42d6-9686-f3e553e24763/resourceGroups/howie-cap-1/providers/Microsoft.CognitiveServices/accounts/foundyav3b/projects/projectav3b/capabilityHosts/caphostproj?api-version=2025-06-01
163-
```
164-
165108
### Optional: account-level defaults with project overrides
166109

167110
Set shared defaults at the account level that apply to all projects:
@@ -202,13 +145,15 @@ DELETE https://management.azure.com/subscriptions/{subscriptionId}/resourceGroup
202145

203146
## Troubleshooting
204147

205-
### Common 409 conflict scenarios
148+
If you're experiencing issues when creating capability hosts, this section provides solutions to the most common problems and errors.
206149

207-
#### 1. **Multiple capability hosts per scope**
150+
### HTTP 409 Conflict errors
208151

209-
**What happens:** You try to create a capability host with a different name when one already exists at the same scope (account or project level).
152+
#### Problem: Multiple capability hosts per scope
210153

211-
**Error example:**
154+
**Symptoms:** You receive a 409 Conflict error when trying to create a capability host, even though you believe the scope is empty.
155+
156+
**Error message:**
212157
```json
213158
{
214159
"error": {
@@ -218,16 +163,27 @@ DELETE https://management.azure.com/subscriptions/{subscriptionId}/resourceGroup
218163
}
219164
```
220165

221-
**How to avoid:**
222-
- **Check existing capability hosts first** before creating new ones
223-
- **Use consistent naming** across all requests for the same scope
224-
- **Query existing resources** to understand current state
166+
**Root cause:** Each account and each project can only have one active capability host. You're trying to create a capability host with a different name when one already exists at the same scope.
167+
168+
**Solution:**
169+
1. **Check existing capability hosts** - Query the scope to see what already exists
170+
2. **Use consistent naming** - Ensure you're using the same name across all requests for the same scope
171+
3. **Review your requirements** - Determine if the existing capability host meets your needs
172+
173+
**Validation steps:**
174+
```http
175+
# For account-level capability hosts
176+
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/capabilityHosts?api-version=2025-06-01
225177
226-
#### 2. **Concurrent operations**
178+
# For project-level capability hosts
179+
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/capabilityHosts?api-version=2025-06-01
180+
```
227181

228-
**What happens:** You try to create a capability host while another operation (update, delete, modify) is in progress at the same scope.
182+
#### Problem: Concurrent operations in progress
229183

230-
**Error example:**
184+
**Symptoms:** You receive a 409 Conflict error indicating that another operation is currently running.
185+
186+
**Error message:**
231187
```json
232188
{
233189
"error": {
@@ -237,14 +193,27 @@ DELETE https://management.azure.com/subscriptions/{subscriptionId}/resourceGroup
237193
}
238194
```
239195

240-
**How to avoid:**
241-
- **Monitor operation status** before making new requests
242-
- **Wait for operations to complete** before starting new ones
196+
**Root cause:** You're trying to create a capability host while another operation (update, delete, modify) is in progress at the same scope.
197+
198+
**Solution:**
199+
1. **Wait for current operation to complete** - Check the status of ongoing operations
200+
2. **Monitor operation progress** - Use the operations API to track completion
201+
3. **Implement retry logic** - Add exponential backoff for temporary conflicts
202+
203+
**Operation monitoring:**
204+
```http
205+
GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/operationResults/{operationId}?api-version=2025-06-01
206+
```
243207

244-
### Error handling patterns
208+
### Best practices for conflict prevention
245209

246-
#### For Application Developers:
210+
#### 1. Pre-request validation
211+
Always verify the current state before making changes:
212+
- Query existing capability hosts in the target scope
213+
- Check for any ongoing operations
214+
- Understand the current configuration
247215

216+
#### 2. Implement retry logic with exponential backoff
248217
```csharp
249218
try
250219
{
@@ -255,7 +224,7 @@ catch (HttpRequestException ex) when (ex.Message.Contains("409"))
255224
{
256225
if (ex.Message.Contains("existing Capability Host with name"))
257226
{
258-
// Different name conflict - check if existing resource meets your needs
227+
// Handle name conflict - check if existing resource is acceptable
259228
var existing = await GetExistingCapabilityHostAsync();
260229
if (IsAcceptable(existing))
261230
{
@@ -268,56 +237,25 @@ catch (HttpRequestException ex) when (ex.Message.Contains("409"))
268237
}
269238
else if (ex.Message.Contains("currently in non creating"))
270239
{
271-
// Resource busy - implement retry
240+
// Handle concurrent operation - implement retry with backoff
272241
await Task.Delay(TimeSpan.FromSeconds(30));
273-
return await CreateCapabilityHostAsync(request); // Retry
242+
return await CreateCapabilityHostAsync(request); // Retry once
274243
}
275244
}
276245
```
277246

278-
#### For CLI/PowerShell Users:
279-
280-
```bash
281-
# Check for existing account-level capability hosts first
282-
az cognitiveservices account capability-host list \
283-
--account-name myaccount \
284-
--resource-group myrg
285-
286-
# Check for existing project-level capability hosts
287-
az cognitiveservices account project capability-host list \
288-
--account-name myaccount \
289-
--project-name myproject \
290-
--resource-group myrg
291-
292-
# If none exist, create new one at account level
293-
az cognitiveservices account capability-host create \
294-
--account-name myaccount \
295-
--resource-group myrg \
296-
--capability-host-name myhost \
297-
--kind Agents
298-
299-
# If creation fails with 409, check operation status
300-
az cognitiveservices account capability-host show \
301-
--account-name myaccount \
302-
--resource-group myrg \
303-
--capability-host-name myhost
304-
```
305-
306-
### Troubleshooting
307-
308-
To minimize 409 conflicts when creating capability hosts:
247+
#### 3. Understanding idempotent behavior
248+
The system supports idempotent create requests:
249+
- **Same name + same configuration** → Returns existing resource (200 OK)
250+
- **Same name + different configuration** → Returns 400 Bad Request
251+
- **Different name** → Returns 409 Conflict
309252

310-
- **Check existing capability hosts** at both account and project levels before creating new ones
311-
- **Use consistent naming** within the same scope (account or project)
312-
- **Implement exponential backoff retry logic** for busy resources
313-
- **Monitor long-running operations** before making new requests
314-
- **Leverage idempotent behavior** for identical requests
315-
- **Don't attempt configuration updates** - delete and recreate instead
316-
- **Monitor operation status** using the operations API
317-
- **Handle error responses** appropriately based on conflict type
318-
- **Understand the scope** - account vs project level capability hosts serve different purposes
253+
#### 4. Configuration change workflow
254+
Since updates aren't supported, follow this sequence for configuration changes:
255+
1. Delete the existing capability host
256+
2. Wait for deletion to complete
257+
3. Create a new capability host with the desired configuration
319258

320-
Following these practices will significantly reduce 409 conflicts and provide a better experience for your users.
321259

322260
## Next steps
323261
- Learn more about the [Standard Agent Setup](standard-agent-setup.md)

0 commit comments

Comments
 (0)