azure-resource-manager - 通过 ResourceManagementClient 触发模板部署时设置参数
问题描述
在代码中通过 ResourceManagementClient 设置部署时,是否有一种简单的方法可以在代码中设置参数,而不必通过 JObject?
解决方案
感谢您的指点。我已经对其进行了概括,因此以下将字典转换为部署请求所需的结构:
public static JObject ConvertProperties(this Dictionary<String, Object> properties)
{
if (properties == null || properties.Count == 0)
{
return null;
}
JObject Output = new JObject();
foreach (KeyValuePair<String, Object> TargetProperty in properties)
{
JObject Child = new JObject();
Child["value"] = JToken.FromObject(TargetProperty.Value);
Output[TargetProperty.Key] = Child;
}
return Output;
}
推荐阅读
- python - Python - 有人可以解释一下这段代码吗?
- excel - Auto run two vba codes when an Excel workbook opens
- swift - DispatchSourceTimer、Timer 和 asyncAfter 的区别?
- ios - 当点击条形按钮项目时,UIFont 会发生变化
- ocaml - 编译后打印ocaml函数
- javascript - 是否可以在某个绝对位置开始/停止 SVG 渐变?
- javascript - Three.js:如何正确配置内存中的场景
- c# - C# 将货币转换为字符串,删除小数点但保留小数,添加 0 以具有固定宽度
- jquery - 每个内部的 Jquery 都移动到父级
- javascript - 使用 Flexbox 使弹出窗口完全响应