我想以编程方式管理我的 Azure 云服务。
我知道 REST API,但我想知道它是否是可用的本机 C# API,就像 Azure 存储一样。
REST API - 托管服务上的操作:http: //msdn.microsoft.com/en-us/library/windowsazure/ee460812.aspx
还是我需要自己包装 REST API,如下文所述?
Azure - 无法以编程方式执行 VIP 交换:Azure - 无法以编程方式执行 VIP 交换
谢谢。
编辑:
CSManage 的建议对我帮助很大。
您可以重用 ServiceManagement 项目并编写自己的客户端(而不是 CSManage)。
使用 ServiceManagementHelper 设置一个通道来执行命令。
例子:
    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);
        }
    }
