Skip to content

Commit 2ba0d62

Browse files
authored
Update capability-hosts.md
1 parent f54623d commit 2ba0d62

File tree

1 file changed

+117
-1
lines changed

1 file changed

+117
-1
lines changed

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

Lines changed: 117 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,123 @@ 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
56+
57+
When creating capability hosts, be aware of these important constraints to avoid conflicts:
58+
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+
### Common 409 conflict scenarios
63+
64+
#### 1. **Multiple capability hosts per scope** ?
65+
66+
**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).
67+
68+
**Error example:**
69+
```json
70+
{
71+
"error": {
72+
"code": "Conflict",
73+
"message": "There is an existing Capability Host with name: existing-host, provisioning state: Succeeded for workspace: /subscriptions/.../workspaces/my-workspace, cannot create a new Capability Host with name: new-host for the same ClientId."
74+
}
75+
}
76+
```
77+
78+
**How to avoid:**
79+
- ? **Check existing capability hosts first** before creating new ones
80+
- ? **Use consistent naming** across all requests for the same scope
81+
- ? **Query existing resources** to understand current state
82+
83+
#### 2. **Concurrent operations** ?
84+
85+
**What happens:** You try to create a capability host while another operation (update, delete, modify) is in progress at the same scope.
86+
87+
**Error example:**
88+
```json
89+
{
90+
"error": {
91+
"code": "Conflict",
92+
"message": "Create: Capability Host my-host is currently in non creating, retry after its complete: /subscriptions/.../workspaces/my-workspace"
93+
}
94+
}
95+
```
96+
97+
**How to avoid:**
98+
- ? **Monitor operation status** before making new requests
99+
- ? **Implement retry logic** with exponential backoff
100+
- ? **Wait for operations to complete** before starting new ones
101+
102+
### Best practices to prevent conflicts
103+
104+
#### 1. **Pre-request validation**
105+
Always check for existing capability hosts before attempting to create new ones:
106+
107+
**For account-level capability hosts:**
108+
```http
109+
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/capabilityHosts?api-version=2025-06-01
110+
```
111+
112+
**For project-level capability hosts:**
113+
```http
114+
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/capabilityHosts?api-version=2025-06-01
115+
```
116+
117+
#### 2. **Implement proper retry logic**
118+
For 409 conflicts due to concurrent operations, implement exponential backoff:
119+
120+
```python
121+
import time
122+
import random
123+
124+
def create_capability_host_with_retry(max_retries=3):
125+
for attempt in range(max_retries):
126+
try:
127+
return create_capability_host()
128+
except requests.HTTPError as e:
129+
if e.response.status_code == 409 and "currently in non creating" in e.response.text:
130+
wait_time = (2 ** attempt) + random.uniform(0, 1)
131+
time.sleep(wait_time)
132+
continue
133+
else:
134+
raise # Different type of conflict, don't retry
135+
raise Exception("Max retries exceeded")
136+
```
137+
138+
#### 3. **Monitor long-running operations**
139+
Capability host operations are asynchronous. Always monitor operation status:
140+
141+
```http
142+
GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/operationResults/{operationId}?api-version=2025-06-01
143+
```
144+
145+
#### 4. **Handle idempotent requests correctly**
146+
The system supports idempotent create requests:
147+
- ? **Same name + same configuration** = Returns existing resource (success)
148+
- ? **Same name + different configuration** = Returns 400 Bad Request
149+
- ? **Different name** = Returns 409 Conflict
150+
151+
### Configuration update limitations
152+
153+
> [!WARNING]
154+
> Configuration updates are not supported. If you need to change configuration, you must delete the existing capability host and recreate it.
155+
156+
**Error example:**
157+
```json
158+
{
159+
"error": {
160+
"code": "InvalidData",
161+
"message": "Update of capability is not currently supported. Please delete and recreate with the new configuration."
162+
}
163+
}
164+
```
165+
166+
**Recommended approach for configuration changes:**
167+
1. Delete the existing capability host
168+
2. Wait for deletion to complete
169+
3. Create a new capability host with the desired configuration
53170

54171
## Recommended setup
55172

@@ -81,7 +198,6 @@ PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{
81198
```
82199
**Project capability host**
83200

84-
This configuration overrides service defaults and any account-level settings. All agents in this project will use your specified resources:
85201
```http
86202
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/capabilityHosts/{name}?api-version=2025-06-01
87203

0 commit comments

Comments
 (0)