microsoft / microsoft/aspire

Model deployment names with foundry need to translate '-' => '_' when creating environment variable names for foundry deployment

Open
#19,674 9 comments 0 reactions 0 assignees View on GitHub
area-app-model area-integrations triage:bot-seen
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

I have some foundry model deployments (`foundry.AddDeployment`) that have hyphens in their names e.g. 'light-model' or 'embeddings-model'.

However at deploy time for my hosted agent, I get these errors:

```
18:13:22 (deploy-eddie-ha) ✗ [ERR] Step 'deploy-eddie-ha' failed.
18:13:22 (deploy-eddie-ha) ✗ Foundry hosted agent for target resource 'eddie' contains environment variable names that are not supported by Foundry Hosted
Agents. Environment variable names must contain only ASCII letters, digits, or underscores. Invalid name(s): 'ConnectionStrings__ai-light-model',
'ConnectionStrings__ai-model', 'ConnectionStrings__embeddings-model', 'services__analytics-api__http__0', 'services__analytics-api__https__0'
18:13:22 (pipeline-execution) ✗ [ERR] Foundry hosted agent for target resource 'eddie' contains environment variable names that are not supported by Foundry
Hosted Agents. Environment variable names must contain only ASCII letters, digits, or underscores. Invalid name(s): 'ConnectionStrings__ai-light-model',
'ConnectionStrings__ai-model', 'ConnectionStrings__embeddings-model', 'services__analytics-api__http__0', 'services__analytics-api__https__0'
18:13:22 (pipeline-execution) ✗ Failed
```

I thought I'll try change them to '_' myself in the names, but that gives me:

```
System.ArgumentException : Resource name 'ai_model' is invalid. Name must contain only ASCII letters, digits, and hyphens. (Parameter 'name')
```

When debugging.

### Expected Behavior

Some option to use '-' or '_'

It seems like there's somewhere it should be auto translating '-' to '_'

### Steps To Reproduce

Aspire project, foundry hosted agent, deployments with '-' in name, deploy to azure.

### Exceptions (if any)

With '_' : `System.ArgumentException : Resource name 'ai_model' is invalid. Name must contain only ASCII letters, digits, and hyphens. (Parameter 'name')` at debug time

With '-': `Foundry hosted agent for target resource 'eddie' contains environment variable names that are not supported by Foundry Hosted
Agents. Environment variable names must contain only ASCII letters, digits, or underscores. Invalid name(s): 'ConnectionStrings__ai-light-model',
'ConnectionStrings__ai-model', 'ConnectionStrings__embeddings-model', 'services__analytics-api__http__0', 'services__analytics-api__https__0'` at deploy time

### Aspire doctor output

```plain
Aspire Environment Check
========================

Aspire
✅ Aspire CLI version 13.5.2 (channel: stable)
✅ Developer Control Plane (DCP) connection health checks succeeded

AppHost
✅ AppHost version 13.5.2 (ecoDriverWeb.AppHost\ecoDriverWeb.AppHost.csproj)

.NET SDK
✅ .NET 10.0.400 installed (x64)

Container Runtime
✅ Docker v29.7.2: running (auto-detected (default)) ← active

Environment
✅ Operating system: Windows 10.0.26200.0
✅ HTTPS development certificate is trusted

Development Tools
✅ Aspire extension for VS Code is installed

Summary: 8 passed, 0 warnings, 0 failed

Aspire CLI Installations
========================

╭───────────────────────────────────────────────┬──────────────────────────────────────────────┬──────────────┬──────────────┬─────────────╮
│ Path │ Version │ Channel │ Route │ PATH status │
├───────────────────────────────────────────────┼──────────────────────────────────────────────┼──────────────┼──────────────┼─────────────┤
│ C:\Users\MatthewPaul\.aspire\bin\aspire.exe │ 13.5.2+a22cec24d76e764b3681977e314ab4a0aeed0 │ stable │ script │ active │
│ (current) │ 240 │ │ │ │
│ C:\Users\MatthewPaul\.dotnet\tools\aspire.EXE │ (not probed) │ (not probed) │ (not probed) │ shadowed │
╰───────────────────────────────────────────────┴──────────────────────────────────────────────┴──────────────┴──────────────┴─────────────╯
```

### Anything else?

This one is a blocker, can't deploy my solution to azure.

Contributor guide

Open the contributing guide

Research direction

Start with the foundry.AddDeployment path in the Aspire project and reproduce deployment using names such as 'light-model' and 'embeddings-model'. Trace how deployment names become hosted-agent environment variable names, while preserving the hyphenated resource names. Done means Azure Foundry accepts the generated names without the reported invalid-environment-variable errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.