[英]Manage my Azure Cloud Services using native C# API?
我想以編程方式管理我的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);
}
}
截至2013年10月,有一組C#庫包裝了Windows Azure Service Management REST API。
它在包名為Microsoft.WindowsAzure.Management.Libraries的 nuget中可用。
這里和這里的博客文章給出了一些概述,文檔可以在MSDN上找到。
正如問題所示,這些庫允許您管理服務(創建部署,擴展部署,執行vip交換等),而不是與blob / table存儲交互。
我有一個非常相似的要求,不幸的是沒有包裝器可以讓你這樣做,另一個答案中提到的那個只有table / blob / queue支持。
然而,有一個稱為csmanage的簡潔解決方案,它是一個使用REST API的命令提示符應用程序,可以讓您管理Azure上的任何內容; 您可以查看源代碼並查看它是如何完成的以及如何自己實現它。
警告 :掌握應用程序的流程是一項非常艱巨的任務,但一旦開始,它就會變得更容易。
提示:看看第104行的CSManageCommand.cs
是魔術開始發生的地方,他們使用WCF與你可以在app.config
看到的API進行通信。
如果您要使用某些已知命令,您可以看到它們出現在以下類中:
您還可以查看Azure Fluent Management Library 。 有一個NuGet包。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.