Skip to content

Commit 0ad7938

Browse files
authored
Update capability-hosts.md
1 parent 007a793 commit 0ad7938

File tree

1 file changed

+137
-41
lines changed

1 file changed

+137
-41
lines changed

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

Lines changed: 137 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -59,45 +59,6 @@ When creating capability hosts, be aware of these important constraints to avoid
5959
> [!IMPORTANT]
6060
> **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.
6161
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-
- **Wait for operations to complete** before starting new ones
100-
10162
### Best practices to prevent conflicts
10263

10364
#### 1. **Pre-request validation**
@@ -159,7 +120,9 @@ A capability host must be configured with the following three properties at eith
159120
|----------|---------|------------------------|-------------|
160121
| `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. |
161122

162-
**Account capability host**
123+
### Account capability host
124+
Create an account-level capability host that provides shared defaults:
125+
163126
```http
164127
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/capabilityHosts/{name}?api-version=2025-06-01
165128
@@ -169,7 +132,9 @@ PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{
169132
}
170133
}
171134
```
172-
**Project capability host**
135+
136+
### Project capability host
137+
Create a project-level capability host that overrides service defaults and any account-level settings:
173138

174139
```http
175140
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/capabilityHosts/{name}?api-version=2025-06-01
@@ -185,6 +150,18 @@ PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{
185150
}
186151
```
187152

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+
188165
### Optional: account-level defaults with project overrides
189166

190167
Set shared defaults at the account level that apply to all projects:
@@ -223,6 +200,125 @@ DELETE https://management.azure.com/subscriptions/{subscriptionId}/resourceGroup
223200
DELETE https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/capabilityHosts/{name}?api-version=2025-06-01
224201
```
225202

203+
## Troubleshooting
204+
205+
### Common 409 conflict scenarios
206+
207+
#### 1. **Multiple capability hosts per scope**
208+
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).
210+
211+
**Error example:**
212+
```json
213+
{
214+
"error": {
215+
"code": "Conflict",
216+
"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."
217+
}
218+
}
219+
```
220+
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
225+
226+
#### 2. **Concurrent operations**
227+
228+
**What happens:** You try to create a capability host while another operation (update, delete, modify) is in progress at the same scope.
229+
230+
**Error example:**
231+
```json
232+
{
233+
"error": {
234+
"code": "Conflict",
235+
"message": "Create: Capability Host my-host is currently in non creating, retry after its complete: /subscriptions/.../workspaces/my-workspace"
236+
}
237+
}
238+
```
239+
240+
**How to avoid:**
241+
- **Monitor operation status** before making new requests
242+
- **Wait for operations to complete** before starting new ones
243+
244+
### Error handling patterns
245+
246+
#### For Application Developers:
247+
248+
```csharp
249+
try
250+
{
251+
var response = await CreateCapabilityHostAsync(request);
252+
return response;
253+
}
254+
catch (HttpRequestException ex) when (ex.Message.Contains("409"))
255+
{
256+
if (ex.Message.Contains("existing Capability Host with name"))
257+
{
258+
// Different name conflict - check if existing resource meets your needs
259+
var existing = await GetExistingCapabilityHostAsync();
260+
if (IsAcceptable(existing))
261+
{
262+
return existing; // Use existing resource
263+
}
264+
else
265+
{
266+
throw new InvalidOperationException("Scope already has a capability host with different name");
267+
}
268+
}
269+
else if (ex.Message.Contains("currently in non creating"))
270+
{
271+
// Resource busy - implement retry
272+
await Task.Delay(TimeSpan.FromSeconds(30));
273+
return await CreateCapabilityHostAsync(request); // Retry
274+
}
275+
}
276+
```
277+
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:
309+
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
319+
320+
Following these practices will significantly reduce 409 conflicts and provide a better experience for your users.
321+
226322
## Next steps
227323
- Learn more about the [Standard Agent Setup](standard-agent-setup.md)
228324
- Get started with [Agent Service](../environment-setup.md)

0 commit comments

Comments
 (0)