2016-09-14 73 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

相关问题