2011-12-14 12 views
3

azureサービスマンゲームメントAPIの使用は比較的新しいです。私はスワップ展開操作を使用しようとしていますが、私は修正できないエラーが発生し続けています。私は青空を初めて知りましたので、この操作についてはまったく間違っているかもしれません。どんな助けでも大歓迎です。ここでは、次のWindows Azureサービスmgmt APIスワップの問題

<Error xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><Code>ResourceNotFound</Code><Message>The resource service name hostedservices is not supported. If it is a new partner service please ensure that the service is registered in RDFE.</Message></Error>" 

が私のコードで例外が

public void swapDeployment() 
    { 

     String operationName = "hostedservices"; 
     String prodName = "HealthMonitor - 21/10/2011 22:36:08"; 
     String sourceName = "SwapTestProject - 13/12/2011 22:23:20"; 

     Uri swapURI = new Uri("https://management.core.windows.net/" 
          + subscriptionId 
          + "/services/" 
          + "hostedservices" 
          + "/stevenRiordanHello/"); 

     HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(swapURI); 

     request.Headers.Add("x-ms-version", "2009-10-01"); 
     request.Method = "POST"; 
     request.ContentType = "application/xml"; 

     String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Swap xmlns=\"http://schemas.microsoft.com/windowsazure\"><Production>"+prodName+"/Production><SourceDeployment>"+sourceName+"</SourceDeployment></Swap>"; 
     byte[] bytes = Encoding.UTF8.GetBytes(xml); 
     request.ContentLength = bytes.Length; 

     X509Store certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser); 

     try 
     { 
      certStore.Open(OpenFlags.ReadOnly); 
     } 
     catch (Exception e) 
     { 
      if (e is CryptographicException) 
      { 
       Console.WriteLine("Error: The store is unreadable."); 
      } 
      else if (e is SecurityException) 
      { 
       Console.WriteLine("Error: You don't have the required permission."); 
      } 
      else if (e is ArgumentException) 
      { 
       Console.WriteLine("Error: Invalid values in the store."); 
      } 
      else 
      { 
       throw; 
      } 
     } 

     X509Certificate2Collection certCollection = certStore.Certificates.Find(X509FindType.FindByThumbprint, thumbprint, false); 
     certStore.Close(); 

     if (0 == certCollection.Count) 
     { 
      throw new Exception("Error: No certificate found containing thumbprint " + thumbprint); 
     } 

     X509Certificate2 certificate = certCollection[0]; 

     request.ClientCertificates.Add(certificate); 

     using (Stream requestStream = request.GetRequestStream()) 
     { 
      requestStream.Write(bytes, 0, bytes.Length); 
     } 
     try 
     { 
      //exception is caught at the end of the line below 
      using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) 
      { 
       if (response.StatusCode != HttpStatusCode.OK) 
       { 
        string message = String.Format("POST failed. Received HTTP {0}", response.StatusCode); 
        throw new ApplicationException(message); 
       } 
      } 
     } 
     catch(WebException e) 
     { 
      StreamReader sr = new StreamReader(e.Response.GetResponseStream()); 
      string errorText = sr.ReadToEnd(); 
     } 
    } 

答えて

1

を発生する場所、私は取得していますエラーが、私はそれに指定されているされて

あなたのサービス名は、大文字を持っているので、それは可能性がありますその中に。それはすべて小文字にする必要があります。しかし、それは言われています...あなたは自分のHTTPクライアントをローリングするのではなく、単にサンプルクライアントを使用するだけの理由はありますか?

この回答を更新してください:有効なXMLを持つ必要がありますが、そのXMLのパラメータも展開名です。これはあまり使われていないものの1つです。通常はGUIDです。この情報を実際に取得する唯一の方法は、GetDeploymentコールまたはGetHostedServiceコールを展開の詳細とともに使用することです。その応答では、名前が表示されます。その名前はあなたが提供したものとはまったく異なります(私はあなたがラベルを使用していると思います)。

+0

返信いただきありがとうございます。サービス名をすべて小文字に変更しましたが、私はまだ同じエラーが発生しています。私のコードはhttp://msdn.microsoft.com/en-us/library/windowsazure/ee460782.aspxからあなたのホストされたサービスをリストしたコードに基づいています。このコードは私のために働いていました。しかし、私が知っているコードはGETのためのもので、スワップ展開操作はPOSTです。 – StevenR

+0

さて、無効なXMLが原因ですか? "" + prodName + "/ Production>"まだ... csmanageでコマンドレットやサンプルクライアントを使用してみませんか? – dunnry

+0

これを見つけて嬉しいですが、私はまだ同じエラーが発生しています。私は唯一の学生です。実際には "csmanageのコマンドレットやサンプルクライアントについて"知らないのです – StevenR

関連する問題