Skip to content

Commit 83d7f50

Browse files
authored
Merge pull request #6421 from howieleung/main
Better doc to avoid 4xx in particular 409
2 parents 6df4319 + 1d8691f commit 83d7f50

File tree

1 file changed

+123
-0
lines changed

1 file changed

+123
-0
lines changed

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

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +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+
## Understand capability host constraints
54+
55+
When creating capability hosts, be aware of these important constraints to avoid conflicts:
56+
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.
58+
59+
- **Configuration updates are not supported**: If you need to change configuration, you must delete the existing capability host and recreate it.
60+
5361

5462
## Recommended setup
5563

@@ -79,6 +87,7 @@ PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{
7987
}
8088
}
8189
```
90+
8291
**Project capability host**
8392

8493
This configuration overrides service defaults and any account-level settings. All agents in this project will use your specified resources:
@@ -134,6 +143,120 @@ DELETE https://management.azure.com/subscriptions/{subscriptionId}/resourceGroup
134143
DELETE https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/capabilityHosts/{name}?api-version=2025-06-01
135144
```
136145

146+
## Troubleshooting
147+
148+
If you're experiencing issues when creating capability hosts, this section provides solutions to the most common problems and errors.
149+
150+
### HTTP 409 Conflict errors
151+
152+
#### Problem: Multiple capability hosts per scope
153+
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:**
157+
```json
158+
{
159+
"error": {
160+
"code": "Conflict",
161+
"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."
162+
}
163+
}
164+
```
165+
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
177+
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+
```
181+
182+
#### Problem: Concurrent operations in progress
183+
184+
**Symptoms:** You receive a 409 Conflict error indicating that another operation is currently running.
185+
186+
**Error message:**
187+
```json
188+
{
189+
"error": {
190+
"code": "Conflict",
191+
"message": "Create: Capability Host my-host is currently in non creating, retry after its complete: /subscriptions/.../workspaces/my-workspace"
192+
}
193+
}
194+
```
195+
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+
```
207+
208+
### Best practices for conflict prevention
209+
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
215+
216+
#### 2. Implement retry logic with exponential backoff
217+
```csharp
218+
try
219+
{
220+
var response = await CreateCapabilityHostAsync(request);
221+
return response;
222+
}
223+
catch (HttpRequestException ex) when (ex.Message.Contains("409"))
224+
{
225+
if (ex.Message.Contains("existing Capability Host with name"))
226+
{
227+
// Handle name conflict - check if existing resource is acceptable
228+
var existing = await GetExistingCapabilityHostAsync();
229+
if (IsAcceptable(existing))
230+
{
231+
return existing; // Use existing resource
232+
}
233+
else
234+
{
235+
throw new InvalidOperationException("Scope already has a capability host with different name");
236+
}
237+
}
238+
else if (ex.Message.Contains("currently in non creating"))
239+
{
240+
// Handle concurrent operation - implement retry with backoff
241+
await Task.Delay(TimeSpan.FromSeconds(30));
242+
return await CreateCapabilityHostAsync(request); // Retry once
243+
}
244+
}
245+
```
246+
247+
#### 3. Understand 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
252+
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
258+
259+
137260
## Next steps
138261
- Learn more about the [Standard Agent Setup](standard-agent-setup.md)
139262
- Get started with [Agent Service](../environment-setup.md)

0 commit comments

Comments
 (0)