2017-09-28 5 views
0
나는 푸른 내 SQL 서버에 연결하고 .NET 응용 프로그램에서 DBS를 나열하려고

으로 금지 된, 그러나 나는푸른 SqlManagementClient은 - TokenCloudCredentials

ForbiddenError: The server failed to authenticate the request. Verify that the certificate is valid and is associated with this subscription.

내가 사용하려고해도가 계속 TokenCloudCredentials를 사용하는 SQL 관리 클라이언트

var authContext = new AuthenticationContext(authority); 
var clientCredential = new ClientCredential(clientId, appKey); 
var result = authContext.AcquireTokenAsync(resource, clientCredential).Result; 
var credentials = new Microsoft.Azure.TokenCloudCredentials(subscriptionId, result.AccessToken); 
var client = new SqlManagementClient(credentials); 
try 
    { 
     var servers = await client.Servers.ListAsync(); 
    } 
    catch (CloudException c) 
    { 
     Console.WriteLine(c.Message); 
     throw; 
    } 

AD 응용 프로그램에는 자원 그룹 및 Azure 관리 API에 대한 액세스 권한이 있습니다. 토큰을 사용하면서 인증서에 대해 불평을 계속하는 이유는 무엇입니까?

편집 : "새로운"유창한 관리 API를 사용하여 관리했습니다. 등록과 연관된 AD 응용 프로그램을 작성하고 자원 그룹에 액세스해야합니다. 그런 다음 자격 증명을 만들고 유창한 API를 초기화하십시오.

using Microsoft.Azure.Management.Fluent; 
using Microsoft.Azure.Management.ResourceManager.Fluent; 
using Microsoft.Azure.Management.ResourceManager.Fluent.Authentication; 
using Microsoft.Azure.Management.ResourceManager.Fluent.Core; 
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 

namespace AzureManagement 
{ 
    public class Program 
    { 
     public static void Main(string[] args) 
     { 
      var azureCredentials = new AzureCredentials(new 
       ServicePrincipalLoginInformation 
      { 
       ClientId = "clientId", 
       ClientSecret = "clientSecret=" 
      }, "tenantId", AzureEnvironment.AzureGlobalCloud); 

      var _azure = Azure 
      .Configure() 
      .WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic) 
      .Authenticate(azureCredentials) 
      .WithSubscription("subscriptionId"); 

      var sql = _azure.SqlServers.List().ToList(); 
      foreach (var s in sql) 
      { 
       var dbs = s.Databases.List().ToList(); 
      } 
      Console.ReadLine(); 
     } 
    } 
} 

답변

1

이것이 지원되는지 확실하지 않습니다. 이 문제에 대한 지원 사례를 작성하십시오.