Azure Germany:拨打changePassword不起作用

问题描述:

我们目前在Azure上托管两个类似的webapps,一个位于国际云端,一个位于德国境内。我们正在使用Graph-API来更改用户的初始密码。这适用于国际版本,但在尝试使用德国版本时会失败。请参阅下面的方法,其中显示了德国应用程序的代码。国际版显然具有其他ID,键和URL,但使用相同的逻辑。Azure Germany:拨打changePassword不起作用

调试代码,我确实得到了一个令牌,并且我可以将该令牌用于POST方法。这是响应(主叫client.PostAsync后):

编号= 42,状态= RanToCompletion,方法= “{NULL}”,结果=“的StatusCode:500, ReasonPhrase: '内部服务器错误',版本:1.1, 内容:System.Net.Http.StreamContent, 接头:\ r \ N {\ r \ n
OCP-AAD-诊断服务器名:5gghBUs/J/tLLA4x7srNaYCSuNTD7zpqDaqBOfa330o = \ r \ n
请求-ID:2258910e-3b51-47a7-bd81-90eb46a31cb0 \ r \ n
客户请求-ID:{myClientId} \ r \ n
}”(...)

我检查了每个ID,密钥和Url十倍。我错过了什么? (客户端ID,用户名等是匿名的)

private async static Task<string> ChangePasswordDE() 
    { 
     try 
     { 

      string clientId = "{myClientID }"; 
      string authority = "https://login.microsoftonline.de/{TenantID}/"; 

      string userName = "[email protected]"; 
      string oldPassword = "thisIsOld1234"; 
      string newPassword = "thisIsNew5678"; 


      var ctx = new AuthenticationContext(authority, false); 
      var pwCred = new UserPasswordCredential(userName, oldPassword); 
      var result = ctx.AcquireTokenAsync("https://graph.cloudapi.de/", clientId, pwCred).Result; 

      var client = new HttpClient(); 
      client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", result.AccessToken); 


      var requestUri = "https://graph.cloudapi.de/me/changePassword?api-version=1.6"; 

      object newPwd = new { currentPassword = oldPassword, newPassword = newPassword }; 

      var body = JsonConvert.SerializeObject(newPwd); 
      Uri uri = new Uri(requestUri); 
      StringContent content = new StringContent(body, System.Text.Encoding.UTF8, "application/json"); 
      Console.WriteLine("Post Async"); 
      var response = client.PostAsync(uri, content).Result; 

      ctx.TokenCache.Clear(); 

      if (response.IsSuccessStatusCode) 
      { 
       Console.WriteLine("Worked!"); 
       return "OK"; 

      } 
      else 
      { 
       Console.WriteLine(response.ReasonPhrase); 
       Console.WriteLine("Did not work!"); 
       return "Error"; 
      } 
     } 
     catch (Exception ex) 
     { 

      Console.WriteLine(ex.InnerException); 
      return ex.InnerException.ToString(); 
     } 

    } 

我们一直在与微软联系。 Azure德国确实实施了Graph API,但截至2017年3月1日,并非所有功能都已完全正常工作。以上述方式使用的ChangePassword就是其中之一。