2016-09-14 49 views

回答

2

我建議你看看Azure資源管理器:https://resources.azure.com。你能找到的情況下,請求URL如下:

enter image description here

對於Authorization頭,請看看this article。我們可以使用C#HttpRequest來編寫代碼。這是我在陰囊中測試的結果。

端點:

https://management.azure.com/subscriptions/<subscription ID > /resourceGroups/jatestgroup/providers/Microsoft.Web/sites/testcore1/instances?api-version=2015-08-01

結果:

enter image description here

我們可以從響應計算實例號JSO ñ。此外,在這個rest API中,需要很長時間才能在Azure門戶中擴展實例時顯示所有實例。

[更新]

與我的意見,我因與文章測試:http://blog.amitapple.com/post/2014/03/access-specific-instance/#.V9tLKyh95hF

以下是我的結果:

enter image description here

請下載庫在here 。有關Windows Azure管理證書的更多信息,請參閱this article

這裏是剪斷代碼:

 var cert = new X509Certificate2(); 

    cert.Import(Convert.FromBase64String("")); 

    var _client = new Microsoft.WindowsAzure.Management.WebSites.WebSiteManagementClient(new Microsoft.WindowsAzure.CertificateCloudCredentials("****", cert)); 

    var ids= await _client.WebSites.GetInstanceIdsAsync("EastAsiawebspace", "testcore1"); 
+0

是否有SDK支持?我正在尋找的是簡單的 - 「C#實例計數」 – SB2055

+1

當我通過Microsoft.Azure.Management.Websites獲取該網站時。 site.SiteConfig爲空。我無法從此程序集中獲得NumberOfWorkers(此程序集是最新版本)。我建議你試試我的方法。這比使用C#SDK更容易。如果您有特殊情況,歡迎創建新線程。 –

+0

感謝您的幫助。 – SB2055

1

您無法從Web應用程序的一個實例中獲取實例數。但是,您可以從門戶網站或Azure ARM API(它是Web Hosting Plan對象上的numberOfWorkers屬性)中獲取它。請注意0​​不適用於Azure Web App。

+0

我試圖通過C#的一些指標送入我的應用程序 - 其中之一是當前實例計數。我可以在C#中使用Azure ARM Api嗎?如果是這樣,你介意提供一個如何獲得這些信息的例子嗎? – SB2055