csmanageを使用してAzureManagementAPIにアクセスしています。これは私のコードです:
private const string subscriberID = "<id>";
static void Main(string[] args)
{
// The thumbprint value of the management certificate.
// You must replace the string with the thumbprint of a
// management certificate associated with your subscription.
string certThumbprint = "<thumbprint>";
// Create a reference to the My certificate store.
X509Store certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
// Try to open the store.
try
{
certStore.Open(OpenFlags.ReadOnly);
}
catch (Exception e)
{
throw;
}
// Find the certificate that matches the thumbprint.
X509Certificate2Collection certCollection = certStore.Certificates.Find(X509FindType.FindByThumbprint, certThumbprint, false);
certStore.Close();
// Check to see if our certificate was added to the collection. If no, throw an error, if yes, create a certificate using it.
if (0 == certCollection.Count)
{
throw new Exception("Error: No certificate found containing thumbprint " + certThumbprint);
}
// Create an X509Certificate2 object using our matching certificate.
X509Certificate2 certificate = certCollection[0];
var serviceManagment = ServiceManagementHelper.CreateServiceManagementChannel("WindowsAzureEndPoint", new X509Certificate2(certificate));
var x = serviceManagment.ListHostedServices(subscriberID);
foreach (HostedService s in x)
{
Console.WriteLine(s.ServiceName);
}
}
これは、コンソールアプリケーションで正常に機能します。ただし、WCFプロジェクトで(サービス実装として)まったく同じコードを実行すると400 - Bad Request
、結果として得られます。
このエラーの原因は何ですか?