コード例 #1
0
 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;
 }
コード例 #2
0
        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;
        }
コード例 #3
0
ファイル: TrafficManagerTests.cs プロジェクト: mortizzle/API
        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);
        }
コード例 #4
0
 public TrafficManagerDefinition(int dnsTtlInSeconds, IEnumerable<TrafficManagerMonitor> monitors, TrafficManagerPolicy policy) : this()
 {
     DnsTtlInSeconds = dnsTtlInSeconds;
     Monitors = monitors.ToList();
     Policy = policy;
 }
コード例 #5
0
 public TrafficManagerDefinition()
 {
     Monitors = new List<TrafficManagerMonitor>();
     Policy = new TrafficManagerPolicy();
     Enabled = true;
 }
コード例 #6
0
 public TrafficManagerDefinition(int dnsTtlInSeconds, IEnumerable <TrafficManagerMonitor> monitors, TrafficManagerPolicy policy) : this()
 {
     DnsTtlInSeconds = dnsTtlInSeconds;
     Monitors        = monitors.ToList();
     Policy          = policy;
 }
コード例 #7
0
 public TrafficManagerDefinition()
 {
     Monitors = new List <TrafficManagerMonitor>();
     Policy   = new TrafficManagerPolicy();
     Enabled  = true;
 }