Azure SQL 服务器 Rest API 访问

Azure SQL Server Rest API access

我正在尝试通过 REST API 从 MS Azure 获取一些关于我的数据库的信息(这只是测试我对 REST 的了解)。使用 C#。但是我需要在哪里输入数据库的登录名和密码?还是不需要?我每次都有 403 http 错误。

WebRequest request = WebRequest.Create("https://management.core.windows.net:8443/{subscriptionId}/services/sqlservers/servers/{servername}/databases/testDB");
       request.Method = "GET";
       request.Headers.Add("x-ms-version", "2012-03-01");
       WebResponse response = request.GetResponse();
       Stream stream = response.GetResponseStream();
       StreamReader reader = new StreamReader(stream, Encoding.UTF8);
       String res = reader.ReadToEnd();
       Console.WriteLine(res);

您尝试执行的 REST API 操作是 Azure Service Management API and they work on a different authentication mechanism. You would either need to provide a X509 based Management Certificate or use Azure AD token for authentication purposes. For more details on authenticating these API requests, please see this link: https://msdn.microsoft.com/en-us/library/azure/ee460782.aspx 的一部分。