Support environment variable placeholders in configuration files
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
首先跟踪 devproxyrc.json 和插件配置文件的配置加载过程,然后阅读 ProxyUtils.ReplaceVariables、IProxyConfiguration.Env 以及 MinimalPermissionsPlugin 现有的替换路径。在决定应在哪里进行解析之前,确认环境值和 env 配置部分是如何表示的。完成标准是:在所示配置文件中一致地解析 ${VAR_NAME} 占位符,而不需要重写脚本,并覆盖 issuer URL 等嵌入式占位符。
由索引模型根据 Issue 内容生成。
描述
Summary
Dev Proxy config files (devproxyrc.json and plugin config files like CrudApiPlugin API files) don't support environment variable placeholders. This means values that vary per environment — like Entra app client IDs or tenant IDs — must be hardcoded in config files, or users need to write scripts to patch them before running Dev Proxy.
Example: the workaround today
In the da-ristorante-api-devproxy-entra sample, we need to inject ENTRA_APP_CLIENT_ID and ENTRA_APP_TENANT_ID into the CrudApiPlugin API files. Because Dev Proxy doesn't support this, the sample includes a Node.js script that reads .env.local and rewrites the JSON config files before each run.
The config file looks like this:
{
"entraAuthConfig": {
"audience": "<ENTRA_APP_CLIENT_ID>",
"issuer": "https://login.microsoftonline.com/<ENTRA_APP_TENANT_ID>/v2.0"
}
}
And the script manually replaces those placeholders with values from env files. This works but adds friction — extra tooling, an extra build step, and mutated config files that can accidentally get committed.
What I'd like to see
Support for environment variable references in config files, for example:
{
"entraAuthConfig": {
"audience": "${ENTRA_APP_CLIENT_ID}",
"issuer": "https://login.microsoftonline.com/${ENTRA_APP_TENANT_ID}/v2.0"
}
}
When Dev Proxy loads a config file, it would resolve ${VAR_NAME} placeholders against environment variables (or the env config section).
Why this seems feasible
Dev Proxy already has closely related infrastructure:
- Path tokens:
~appFolderand~dataFolderare resolved viaProxyUtils.ReplacePathTokenswhen loading config/plugin paths @dynamictokens: used in mock responses and rate limiting headers, resolved at runtimeProxyUtils.ReplaceVariables: a general-purpose string replacement utility that replaces variable references in a string given a dictionary of valuesIProxyConfiguration.Env: the proxy configuration already exposes aDictionary<string, string> EnvpropertyMinimalPermissionsPluginalready usesProxyUtils.ReplaceVariables(fileContents, ProxyConfiguration.Env, v => $"{{{v}}}")to resolve{VAR}placeholders in OpenAPI spec files
The pattern is already proven in plugins — it just needs to be applied when loading configuration files too.
Benefits
- No more wrapper scripts to inject environment-specific values
- Config files stay clean and committable (no secrets, no environment-specific values)
- Consistent with how other tools handle this (Docker Compose, Azure Pipelines, GitHub Actions, etc.)
- Works naturally with
.envfiles and CI/CD environments
- 主要语言
- C#
- 星标
- 833
- 派生
- 90
- 平均合并
- 18 小时 41 分钟
- 30 天内合并 PR
- 45
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
dotnet/dev-proxy 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
waiting for response
难度 4/5 3-5 天 新手友好度 28/100
dotnet/dev-proxy#1914 · 1 条评论 ·
维护者通常 1 天内回复
-
MockStdioResponsePlugin: @stdin.body.id placeholder fails to resolve when messages arrive back-to-back after an id-less message可能重新可做 @garrytrinder 于 85 天前认领,目前没有进行中的 PR。 未关闭
dotnet/dev-proxy#1757 · 1 个 reaction · 已指派 2 人 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 55/100
维护者通常 1 天内回复
相似的 Issue
-
S: Untriaged
难度 2/5 1-3 小时 新手友好度 78/100
space-wizards/space-station-14#46357 ·
维护者通常 1 天内回复
-
Versioning_oM: Remove unneeded depeendecy on Test_oM可能已有人在做 @IsakNaslundBh 今天认领。 未关闭type:bug type:compliance
难度 2/5 1 小时以内 新手友好度 85/100
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 66/100
MicrosoftLearning/PL-400_Microsoft-Power-Platform-Developer#231 ·
-
难度 2/5 1-3 小时 新手友好度 66/100
joinrpg/joinrpg-net#5313 ·
维护者通常 1 天内回复