首页 > 解决方案 > 通过 ResourceManagementClient 触发模板部署时设置参数

问题描述

在代码中通过 ResourceManagementClient 设置部署时,是否有一种简单的方法可以在代码中设置参数,而不必通过 JObject?

标签: azure-resource-manager

解决方案


感谢您的指点。我已经对其进行了概括,因此以下将字典转换为部署请求所需的结构:

  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;
        }

推荐阅读