Sim*_*raa 11 c# api rest azure
我想以编程方式管理我的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);
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个非常类似的要求,不幸的是没有包装器可以让你做到这一点,另一个答案中提到的包装器只有表/blob/队列支持。
然而,有一个名为 csmanage 的简洁解决方案,它是一个命令提示符应用程序,在底层使用 REST API,让您可以管理 Azure 上的几乎所有内容;您可以查看源代码并了解它是如何完成的以及如何自己实现。
警告的话:掌握应用程序的流程是一项艰巨的任务,但一旦开始,事情就会变得更容易。
提示:看一下CSManageCommand.cs第 104 行,神奇的事情开始发生,他们使用 WCF 与 API 进行通信,您可以在app.config.
如果您想使用某些已知命令,您可以看到它们出现在以下类中:
