Azure连接失败错误

时间:2012-10-16 07:10:15

标签: azure acs

我正在使用此https://xxxx.accesscontrol.windows.net/v2/mgmt/service网址获取服务

ACS令牌,我收到此错误,

  

ACS60018:URI   'https://xxx.accesscontrol.windows.net/v2/mgmt/service'无效   因为它不是基于   'https://xxxx.accesscontrol.windows.net/v2/mgmt/service/'。跟踪ID:   ed498472-6a04-4d51-a6ba-4786f0c67212。时间戳:2012-10-16 07:07:09Z

如果我尝试使用应用程序

class Program
    {
        public const string serviceIdentityUsernameForManagement = "ManagementClient";
        public const string serviceIdentityPasswordForManagement = "xxxxxxxxxxx=";
        public const string serviceNamespace = "xxxxx";
        public const string acsHostName = "accesscontrol.windows.net";
        public const string acsManagementServicesRelativeUrl = "v2/mgmt/service/";
        static string cachedSwtToken;        

        static void Main(string[] args)
        {
            //
            // Request a token from ACS
            //
            WebClient client = new WebClient();
            client.BaseAddress = string.Format(CultureInfo.CurrentCulture,
                                               "https://{0}.{1}",
                                               serviceNamespace,
                                               acsHostName);
            NameValueCollection values = new NameValueCollection();
            values.Add("grant_type", "client_credentials");
            values.Add("client_id", serviceIdentityUsernameForManagement);
            values.Add("client_secret", serviceIdentityPasswordForManagement);
            values.Add("scope", client.BaseAddress + acsManagementServicesRelativeUrl);

            byte[] responseBytes = client.UploadValues("/v2/OAuth2-13", "POST", values);

            string response = Encoding.UTF8.GetString(responseBytes);

            // Parse the JSON response and return the access token 
            JavaScriptSerializer serializer = new JavaScriptSerializer();

            Dictionary<string, object> decodedDictionary = serializer.DeserializeObject(response) as Dictionary<string, object>;

            string returnToken= decodedDictionary["access_token"] as string;      
        }
    }

我收到此错误

  

“连接尝试失败,因为连接方没有   在一段时间后正确回应,或建立连接   失败,因为连接的主机无法响应   157.56.160.192:443" }

团队可以告诉我如何使用c#代码

获取ACS令牌

先谢谢, Saravanan

1 个答案:

答案 0 :(得分:3)

此错误:

  

ACS60018:URI“https://xxx.accesscontrol.windows.net/v2/mgmt/service”无效,因为它不基于'https://xxxx.accesscontrol.windows.net/v2/管理/服务/”。跟踪ID:ed498472-6a04-4d51-a6ba-4786f0c67212。时间戳:2012-10-16 07:07:09Z

是由管理URI上缺少尾部斜杠引起的(OData规范特别关注此内容)。