【问题标题】:Creating Azure Traffic Manager through REST API - unexpected behaviour通过 REST API 创建 Azure 流量管理器 - 意外行为
【发布时间】:2013-12-31 22:49:36
【问题描述】:

我使用 2011-10-01 MS 版本通过其 REST API 创建了流量管理器。

我关注的资源 -

流量管理器已成功创建。万事如意。

但在 30 分钟后,流量管理器将进入 INACTIVE 状态,并且其所有端点都已消失。它显示没有与之关联的端点。

我不确定周围发生了什么。是 Azure 的问题吗?还是 REST API 问题?还是我创建流量管理器问题的方式。

PS - 我按照这个示例进行 REST API 调用 - http://msdn.microsoft.com/en-us/library/windowsazure/gg651127.aspx

任何帮助将不胜感激。

更新1

参数

  • SubscriptionID - 来自 publishsettings 的有效 GUID
  • 证书 - 我交叉检查了本地证书存储中存在的有效证书
  • endpoint1 域名 - JASH13.CLOUDAPP.NET
  • endpoint2 域名 - JASH23.CLOUDAPP.NET

在 REST API 调用级别没有错误。一切顺利。

个人资料创建 -

 // X.509 certificate variables.
            X509Store certStore = null;
            X509Certificate2Collection certCollection = null;
            X509Certificate2 certificate = null;

            // Request and response variables.
            HttpWebRequest httpWebRequest = null;
            HttpWebResponse httpWebResponse = null;

            // Stream variables.
            Stream responseStream = null;
            StreamReader reader = null;

            // URI variable.
            Uri requestUri = null;

            // The thumbprint for the certificate. This certificate would have been
            // previously added as a management certificate within the Windows Azure management portal.
            string thumbPrint = CertificateThumbprint;

            // Open the certificate store for the current user.
            certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
            certStore.Open(OpenFlags.ReadOnly);

            // Find the certificate with the specified thumbprint.
            certCollection = certStore.Certificates.Find(
                                 X509FindType.FindByThumbprint,
                                 thumbPrint,
                                 false);

            // Close the certificate store.
            certStore.Close();

            // Check to see if a matching certificate was found.
            if (0 == certCollection.Count)
            {
                throw new Exception("No certificate found containing thumbprint " + thumbPrint);
            }

            // A matching certificate was found.
            certificate = certCollection[0];


            // Create the request.
            requestUri = new Uri("https://management.core.windows.net/"
                                 + SubscriptionId
                                 + "/services/WATM/profiles");

            httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(requestUri);

            // Add the certificate to the request.
            httpWebRequest.ClientCertificates.Add(certificate);
            httpWebRequest.Method = "POST";
            httpWebRequest.Headers.Add("x-ms-version", "2011-10-01");


            string str = @"<Profile xmlns=""http://schemas.microsoft.com/windowsazure""><DomainName>" + ProfileDomain + "</DomainName><Name>" + ProfileName + "</Name></Profile>";
            byte[] bodyStart = System.Text.Encoding.UTF8.GetBytes(str.ToString());
            Stream dataStream = httpWebRequest.GetRequestStream();
            dataStream.Write(bodyStart, 0, str.ToString().Length);

            // Make the call using the web request.
            httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            // Parse the web response.
            responseStream = httpWebResponse.GetResponseStream();
            reader = new StreamReader(responseStream);

            // Close the resources no longer needed.
            httpWebResponse.Close();
            responseStream.Close();
            reader.Close();

定义创建-

 // X.509 certificate variables.
            X509Store certStore = null;
            X509Certificate2Collection certCollection = null;
            X509Certificate2 certificate = null;

            // Request and response variables.
            HttpWebRequest httpWebRequest = null;
            HttpWebResponse httpWebResponse = null;

            // Stream variables.
            Stream responseStream = null;
            StreamReader reader = null;

            // URI variable.
            Uri requestUri = null;

            // The thumbprint for the certificate. This certificate would have been
            // previously added as a management certificate within the Windows Azure management portal.
            string thumbPrint = CertificateThumbprint;

            // Open the certificate store for the current user.
            certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
            certStore.Open(OpenFlags.ReadOnly);

            // Find the certificate with the specified thumbprint.
            certCollection = certStore.Certificates.Find(
                                 X509FindType.FindByThumbprint,
                                 thumbPrint,
                                 false);

            // Close the certificate store.
            certStore.Close();

            // Check to see if a matching certificate was found.
            if (0 == certCollection.Count)
            {
                throw new Exception("No certificate found containing thumbprint " + thumbPrint);
            }

            // A matching certificate was found.
            certificate = certCollection[0];


            // Create the request.
            requestUri = new Uri("https://management.core.windows.net/"
                                 + SubscriptionId
                                 + "/services/WATM/profiles/" + ProfileName + "/definitions");

            httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(requestUri);

            // Add the certificate to the request.
            httpWebRequest.ClientCertificates.Add(certificate);
            httpWebRequest.Method = "POST";
            httpWebRequest.Headers.Add("x-ms-version", "2011-10-01");


            string str = @"<Definition xmlns=""http://schemas.microsoft.com/windowsazure""><DnsOptions><TimeToLiveInSeconds>300</TimeToLiveInSeconds></DnsOptions><Monitors><Monitor><IntervalInSeconds>30</IntervalInSeconds><TimeoutInSeconds>10</TimeoutInSeconds><ToleratedNumberOfFailures>3</ToleratedNumberOfFailures><Protocol>HTTP</Protocol><Port>80</Port><HttpOptions><Verb>GET</Verb><RelativePath>/</RelativePath><ExpectedStatusCode>200</ExpectedStatusCode></HttpOptions></Monitor></Monitors><Policy><LoadBalancingMethod>RoundRobin</LoadBalancingMethod><Endpoints><Endpoint><DomainName>" + PrimaryService + "</DomainName><Status>Enabled</Status></Endpoint><Endpoint><DomainName>" + SecondaryService + "</DomainName><Status>Enabled</Status></Endpoint></Endpoints></Policy></Definition>";
            byte[] bodyStart = System.Text.Encoding.UTF8.GetBytes(str.ToString());
            Stream dataStream = httpWebRequest.GetRequestStream();
            dataStream.Write(bodyStart, 0, str.ToString().Length);

            // Make the call using the web request.
            httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            // Parse the web response.
            responseStream = httpWebResponse.GetResponseStream();
            reader = new StreamReader(responseStream);

            // Close the resources no longer needed.
            httpWebResponse.Close();
            responseStream.Close();
            reader.Close();

更新2 TM 进入非活动状态后,我使用 REST API 检查了配置文件定义。在那里我找不到任何端点。他们不见了。

        <Definitions xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <Definition>
    <DnsOptions>
    <TimeToLiveInSeconds>300</TimeToLiveInSeconds>
    </DnsOptions>
    <Status>Enabled</Status>
    <Version>1</Version>
    <Monitors>
    <Monitor>
<IntervalInSeconds>30</IntervalInSeconds>
<TimeoutInSeconds>10</TimeoutInSeconds>
<ToleratedNumberOfFailures>3</ToleratedNumberOfFailures>
<Protocol>HTTP</Protocol>
<Port>80</Port>
<HttpOptions>
<Verb>GET</Verb>
<RelativePath>/</RelativePath>
<ExpectedStatusCode>200</ExpectedStatusCode>
</HttpOptions>
</Monitor>
</Monitors>
<Policy>
<LoadBalancingMethod>Performance</LoadBalancingMethod>
<Endpoints/>
<MonitorStatus>Inactive</MonitorStatus>
</Policy>
</Definition>
</Definitions>

更新3 这种零星的行为只发生在特定的云服务和 TM 配置文件/定义中。当我创建一组新的云服务和 TM 配置文件时,一切似乎都运行良好。我对此进行了多次测试。所以唯一的问题是以下参数。

  • endpoint1 域名 - JASH13.CLOUDAPP.NET
  • endpoint2域名-JASH23.CLOUDAPP.NET
  • TM 域 - ramitm.trafficmanager.net
  • TM 配置文件名称 - ramitm

【问题讨论】:

  • 请分享一些代码。
  • @GauravMantri,在上面添加了代码。
  • @ramiramilu 您可以分享有关您创建的 WATM 配置文件的任何信息吗? WATM URL 或您的 cloudapp.net URL 之一会很有帮助。我可以在我们的内部日志中查找这些信息,看看发生了什么。
  • @kwill 当然。这些是详细信息 - WATM - ramitm.trafficmanager.net endpoint1 - jash13.cloudapp.net endpoint2 - jash23.cloudapp.net
  • @kwill - 一旦 TM 进入非活动状态,我查看了配置文件定义。我无法在定义中找到端点。

标签: azure


【解决方案1】:

这似乎是一些用于非常快速的 REST API 操作的 DNS 问题。我没能找到问题的症结所在,但我就是这样解决的。

以前我遇到过这个问题 - 创建 -> 删除 -> 重新创建

现在我这样做了 - 创建 -> 删除 -> 延迟 -> 重新创建

我认为通过引入延迟组件,我给了 Azure 足够的时间来解决所有 DNS 和基础架构并在那里更新它们。因此,在引入延迟之后,我没有遇到问题。延迟可能是 5 - 10 分钟。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-04-27
    • 2020-07-05
    • 1970-01-01
    • 2018-10-25
    • 1970-01-01
    • 1970-01-01
    • 2019-08-24
    相关资源
    最近更新 更多