简体   繁体   English

使用.net检索Azure虚拟网络信息

[英]Retrieve Azure Virtual network information using .net

i am new to Microsoft azure, i am trying to interact with azure using its .net sdk. 我是Microsoft azure的新手,我正尝试使用其.net sdk与azure进行交互。 How can i retrieve the list of virtual networks and the corresponding subnets created in Azure, using .net? 如何使用.net检索在Azure中创建的虚拟网络和相应子网的列表? Any help would be greatly appreciated 任何帮助将不胜感激

You can use the Azure Management Libraries, it is in a nuget package called: microsoft.windowsazure.management 您可以使用Azure管理库,它位于一个名为microsoft.windowsazure.management的nuget程序包中。

Here is a sample: 这是一个示例:

var cred = new Microsoft.Azure.CertificateCloudCredentials("yoursubid", new X509Certificate2(Convert.FromBase64String("yourcert")));

using (var netclient = new NetworkManagementClient(cred))
{
  var networks = netclient.Networks.List();
  Console.WriteLine("Networks:");
  networks.VirtualNetworkSites.ToList().ForEach(x =>
  {
    Console.WriteLine(x.Name);
    x.Subnets.ToList().ForEach(y => Console.WriteLine(y.Name));
  }
 );

} }

If you need a more elaborate example look at this blog post. 如果您需要更详细的示例,请参阅此博客文章。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM