title: Manage my Azure Cloud Services using native C# API?
body: <p>I would like to manage my Azure Cloud Services programmatically.</p>
  
  <p>I am aware of the REST API but I am wondering if the is a native C# API available just like there is with Azure Storage.</p>
  
  <p>REST API - Operations on Hosted Services: <a href="http://msdn.microsoft.com/en-us/library/windowsazure/ee460812.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/windowsazure/ee460812.aspx</a></p>
  
  <p>Or do I need to wrap the REST API myself as described in the post below?</p>
  
  <p>Azure - Cannot programmatically perform VIP Swap: <a href="https://stackoverflow.com/questions/8460305/azure-cannot-programmatically-perform-vip-swap">Azure - Cannot programmatically perform VIP Swap</a></p>
  
  <p>Thanks.</p>
  
  <hr>
  
  <p><strong>Edit:</strong></p>
  
  <p>The CSManage suggestion helped me a lot.</p>
  
  <p>You can reuse the ServiceManagement project and write your own client (instead of CSManage).</p>
  
  <p>Use the ServiceManagementHelper to setup a channel to execute the commands.</p>
  
  <p>Example:</p>
  
  <pre><code>    public static string SubscriptionId { get; set; }
      public static string CertificateThumbprint { get; set; }
  
      public static X509Certificate2 Certificate { get; set; }
  
      private void button1_Click(object sender, EventArgs e)
      {
          SubscriptionId = ConfigurationManager.AppSettings["SubscriptionId"];
          CertificateThumbprint = ConfigurationManager.AppSettings["CertificateThumbprint"];
  
          X509Store certificateStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
          certificateStore.Open(OpenFlags.ReadOnly);
          X509Certificate2Collection certs = certificateStore.Certificates.Find(X509FindType.FindByThumbprint, CertificateThumbprint, false);
          if (certs.Count != 1)
          {
              MessageBox.Show("Client certificate cannot be found. Please check the config file. ");
              return;
          }
          Certificate = certs[0];
  
          // List Hosted Services
          var channel = ServiceManagementHelper.CreateServiceManagementChannel("WindowsAzureEndPoint", Certificate);
          var lhs = channel.ListHostedServices(SubscriptionId);
          foreach (HostedService hs in lhs)
          {
              MessageBox.Show(hs.ServiceName);
          }
      }
  </code></pre>