【发布时间】:2020-08-05 06:31:10
【问题描述】:
我正在使用https://www.nuget.org/packages/Microsoft.Azure.Management.Fluent 以编程方式(C#.NET-Core Web 应用程序)在 Azure 中获取资源,并尝试通过提供如下服务主体(CS)来获取资源信息...
string subscriptionId = "xxx";
string clientId = "xxx";
string tenantId = "xxx";
string clientSecret = "xxx";
AzureCredentials cred = new AzureCredentialsFactory()
.FromServicePrincipal(
clientId,
clientSecret,
tenantId,
AzureEnvironment.AzureGlobalCloud
);
var azure = Azure.Configure()
.WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic)
.Authenticate(cred)
.WithSubscription(subscriptionId);
任何示例代码(C#.NET-Core Web 应用程序),以找出 端点统计信息(遍历 NSG 中的开放端口并详细列出它们)和 危险端点 (遍历 NSG 中的开放端口并识别 3389/22 等端口)。
请提供以上建议。
谢谢
【问题讨论】:
-
请提供您尝试过的代码。
-
foreach (var nsg in azure.NetworkSecurityGroups.List()) { foreach (var nic in nsg.NetworkInterfaceIds) { try { // 如何查找端点统计信息(循环通过 NSG 中的开放端口并详细列出它们) //and Dangerous Endpoints } catch { } } }
-
@AnirbanGoswami,只是想确认一下,您想列出 NSG 中的所有端口 -> 入站安全规则?
标签: c# azure .net-core azure-management-api