/// <summary> /// Parses the result of https://management.azure.com/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.ClassicCompute/domainNames/{2}/slots/{3}?api-version=2016-11-01 /// </summary> public static CloudServiceProperties ParseCloudServiceProperties(string propertiesString) { try { var cloudService = new CloudServiceProperties(); var jObject = JObject.Parse(propertiesString); var properties = jObject["properties"]; cloudService.Uri = new Uri(properties["uri"].ToString()); // This contains the cscfg format configuration in XML format var configuration = properties["configuration"].ToString(); var xmlConfig = new XmlDocument(); xmlConfig.LoadXml(configuration); var instancesElement = xmlConfig.GetElementsByTagName("Instances")[0]; cloudService.InstanceCount = int.Parse(instancesElement.Attributes["count"].InnerText); return(cloudService); } catch (Exception e) { throw new AzureManagementException($"Failed to parse cloud service properties string: {propertiesString}", e); } }
internal static CloudServiceData DeserializeCloudServiceData(JsonElement element) { Optional <CloudServiceProperties> properties = default; IDictionary <string, string> tags = default; AzureLocation location = default; ResourceIdentifier id = default; string name = default; ResourceType type = default; SystemData systemData = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } properties = CloudServiceProperties.DeserializeCloudServiceProperties(property.Value); continue; } if (property.NameEquals("tags")) { Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (var property0 in property.Value.EnumerateObject()) { dictionary.Add(property0.Name, property0.Value.GetString()); } tags = dictionary; continue; } if (property.NameEquals("location")) { location = property.Value.GetString(); continue; } if (property.NameEquals("id")) { id = new ResourceIdentifier(property.Value.GetString()); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = property.Value.GetString(); continue; } if (property.NameEquals("systemData")) { systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString()); continue; } } return(new CloudServiceData(id, name, type, systemData, tags, location, properties.Value)); }
internal CloudServiceData(ResourceIdentifier id, string name, ResourceType type, IDictionary <string, string> tags, Location location, CloudServiceProperties properties) : base(id, name, type, tags, location) { Properties = properties; }
internal CloudServiceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary <string, string> tags, AzureLocation location, CloudServiceProperties properties) : base(id, name, resourceType, systemData, tags, location) { Properties = properties; }