internal TrafficManagerDefinition(XElement xml, TrafficManagerProfile parent)
 {
     var ns = XmlNamespaces.WindowsAzure;
     Version = (string)xml.Element(ns + "Version");
     DnsTtlInSeconds = (int)xml.Element(ns + "DnsOptions").Element(ns + "TimeToLiveInSeconds");
     Enabled = (string)xml.Element(ns + "Status") != "Disabled";
     Monitors = xml.Element(ns + "Monitors").Elements(ns + "Monitor").Select(xe => new TrafficManagerMonitor(xe)).ToList();
     Policy = new TrafficManagerPolicy(xml.Element(ns + "Policy"));
     Parent = parent;
 }
        internal TrafficManagerDefinition(XElement xml, TrafficManagerProfile parent)
        {
            var ns = XmlNamespaces.WindowsAzure;

            Version         = (string)xml.Element(ns + "Version");
            DnsTtlInSeconds = (int)xml.Element(ns + "DnsOptions").Element(ns + "TimeToLiveInSeconds");
            Enabled         = (string)xml.Element(ns + "Status") != "Disabled";
            Monitors        = xml.Element(ns + "Monitors").Elements(ns + "Monitor").Select(xe => new TrafficManagerMonitor(xe)).ToList();
            Policy          = new TrafficManagerPolicy(xml.Element(ns + "Policy"));
            Parent          = parent;
        }
Beispiel #3
0
        public async Task CanUseTrafficManager()
        {
            Debug.WriteLine("Retrieving traffic manager profile");
            var profiles = await GetProfilesAsync();
            Assert.AreEqual(profiles.Length, 1);
            Assert.AreEqual(profiles[0].Name, Profile.Name);

            var monitor = new TrafficManagerMonitor(80, new TrafficManagerHttpOptions ("/foo"))
            {
                Protocol = MonitorProtocol.HTTPS
            };

            var policy = new TrafficManagerPolicy (new[] { new TrafficManagerEndpoint (Parent.CloudService.Name + ".cloudapp.net") })
            {
                LoadBalancingMethod = LoadBalancingMethod.RoundRobin
            };
            
            var defn = new TrafficManagerDefinition(3600, new[] { monitor }, policy);

            Debug.WriteLine("Creating traffic manager definition");
            await Profile.AddDefinitionAsync(defn);

            Debug.WriteLine("Retrieving traffic manager definition");
            var allDefns = await Profile.Definitions.AsTask();
            Assert.AreEqual(1, allDefns.Length);
            
            var defn2 = allDefns[0];
            Assert.AreEqual(defn.DnsTtlInSeconds, defn2.DnsTtlInSeconds);
            
            Assert.AreEqual(1, defn2.Monitors.Count);
            Assert.AreEqual(defn.Version, defn2.Version);
            Assert.AreEqual(monitor.IntervalInSeconds, defn2.Monitors[0].IntervalInSeconds);
            Assert.AreEqual(monitor.TimeoutInSeconds, defn2.Monitors[0].TimeoutInSeconds);
            Assert.AreEqual(monitor.Protocol, defn2.Monitors[0].Protocol);

            Assert.AreEqual(policy.LoadBalancingMethod, defn2.Policy.LoadBalancingMethod);
            Assert.AreEqual(1, defn2.Policy.EndPoints.Count);
            Assert.AreEqual(policy.EndPoints[0].DomainName, defn2.Policy.EndPoints[0].DomainName);

            Debug.WriteLine("Enabling profile");
            await Profile.UpdateAsync(true, "1");
            var result = Subscription.TrafficManagerProfiles.AsEnumerable().Single(x => x.Name == Profile.Name);
            Assert.AreEqual(true, result.Enabled);
        }
 public TrafficManagerDefinition(int dnsTtlInSeconds, IEnumerable<TrafficManagerMonitor> monitors, TrafficManagerPolicy policy) : this()
 {
     DnsTtlInSeconds = dnsTtlInSeconds;
     Monitors = monitors.ToList();
     Policy = policy;
 }
 public TrafficManagerDefinition()
 {
     Monitors = new List<TrafficManagerMonitor>();
     Policy = new TrafficManagerPolicy();
     Enabled = true;
 }
 public TrafficManagerDefinition(int dnsTtlInSeconds, IEnumerable <TrafficManagerMonitor> monitors, TrafficManagerPolicy policy) : this()
 {
     DnsTtlInSeconds = dnsTtlInSeconds;
     Monitors        = monitors.ToList();
     Policy          = policy;
 }
 public TrafficManagerDefinition()
 {
     Monitors = new List <TrafficManagerMonitor>();
     Policy   = new TrafficManagerPolicy();
     Enabled  = true;
 }