private static void AddAdditionalParameters(JObject parametersObject, ArmTemplate armTemplate) { foreach (var additionalResource in armTemplate.AdditionalResourceNames) { parametersObject.Add(CreateParameterProperty(additionalResource)); } }
protected override ArmTemplate TransformInner(ArmTemplate armTemplate, IArmPropertyValueResolver armPropertyValueResolver) { JObject variables = CreateVariablesObject(armTemplate); armTemplate.Json.AddFirst(new JProperty(ArmTemplatePropertyNameConstants.Variables, variables)); return(armTemplate); }
protected override ArmTemplate TransformInner(ArmTemplate armTemplate, IArmPropertyValueResolver armPropertyValueResolver) { armTemplate.Json.AddFirst(new JProperty(ArmTemplatePropertyNameConstants.Variables, new JObject())); armTemplate.Json.AddFirst(BuildTemplateParameters(armTemplate)); armTemplate.Json.AddFirst(new JProperty(ArmTemplatePropertyNameConstants.ContentVersion, ArmPropertyValueConstants.ContentVersion)); armTemplate.Json.AddFirst(new JProperty("$schema", ArmPropertyValueConstants.TemplateSchema)); return(armTemplate); }
protected override ArmTemplate TransformInner(ArmTemplate armTemplate, IArmPropertyValueResolver armPropertyValueResolver) { var properties = armTemplate.Json.SelectToken("properties"); var parts = properties.SelectToken("lenses.0.parts"); UpdateParts(parts, armPropertyValueResolver); UpdateTemplateMetadata(armTemplate.Json, armPropertyValueResolver); return(armTemplate); }
private static JObject CreateVariablesObject(ArmTemplate armTemplate) { var parametersObject = new JObject( CreateParameterProperty(ArmTemplateDynamicProperty.AppInsightsName.DynamicValue), CreateParameterProperty(ArmTemplateDynamicProperty.DashboardName.DynamicValue), CreateParameterProperty(ArmTemplateDynamicProperty.DashboardDisplayName.DynamicValue)); AddAdditionalParameters(parametersObject, armTemplate); return(parametersObject); }
protected override ArmTemplate TransformInner(ArmTemplate armTemplate, IArmPropertyValueResolver armPropertyValueResolver) { var dependencies = new JArray(); dependencies.Add(WrapVariableSelector(armPropertyValueResolver.GetValue(ArmTemplateDynamicProperty.AppInsightsName))); foreach (var additionalResource in armTemplate.AdditionalResourceNames) { dependencies.Add(WrapVariableSelector(armPropertyValueResolver.GetValue(additionalResource))); } armTemplate.Json.Add(new JProperty("dependsOn", dependencies)); return(armTemplate); }
protected override ArmTemplate TransformInner(ArmTemplate armTemplate, IArmPropertyValueResolver armPropertyValueResolver) { var resourceIdProperties = armTemplate.Json.GetAllChildProperties("resourceId"); var additionalResourceNames = new HashSet <string>(); foreach (var resourceIdProperty in resourceIdProperties) { var resourceId = new ResourceId(resourceIdProperty.Value.Value <string>(), armPropertyValueResolver); resourceIdProperty.Value = resourceId.ToParameterisedString(); additionalResourceNames.Add(resourceId.ResourceParameterName); } armTemplate.AdditionalResourceNames.AddRange(additionalResourceNames); return(armTemplate); }
protected override ArmTemplate TransformInner(ArmTemplate armTemplate, IArmPropertyValueResolver armPropertyValueResolver) { var resources = new JArray(); var properties = armTemplate.Json.Properties(); var resourcesObject = new JObject(); foreach (var property in properties) { resourcesObject.Add(property); } resources.Add(resourcesObject); armTemplate.ReplaceJson(new JObject(new JProperty("resources", resources))); return(armTemplate); }
private static JProperty BuildTemplateParameters(ArmTemplate armTemplate) { var parameters = new JObject( CreateParameterProperty(ArmTemplateDynamicProperty.AppInsightsName), CreateParameterProperty(ArmTemplateDynamicProperty.DashboardName), CreateParameterProperty(ArmTemplateDynamicProperty.DashboardDisplayName), CreateParameterProperty(ArmTemplateDynamicProperty.ResourceGroupName), CreateParameterProperty(ArmTemplateDynamicProperty.SubscriptionId) ); foreach (var additionalParameter in armTemplate.AdditionalResourceNames) { parameters.Add(CreateParameterProperty(additionalParameter)); } return(new JProperty(ArmTemplatePropertyNameConstants.Parameters, parameters)); }
protected abstract ArmTemplate TransformInner(ArmTemplate armTemplate, IArmPropertyValueResolver armPropertyValueResolver);
public ArmTemplate Transform(ArmTemplate armTemplate, IArmPropertyValueResolver armPropertyValueResolver) { armTemplate = this.TransformInner(armTemplate, armPropertyValueResolver); return(this.nextTransformer != null?this.nextTransformer.Transform(armTemplate, armPropertyValueResolver) : armTemplate); }