【发布时间】:2020-07-14 09:43:34
【问题描述】:
我正在使用Fluent 以编程方式获取 Azure 中的资源(C# .NET-Core Web 应用程序),并尝试通过提供如下服务主体来获取资源信息:
string subscriptionId="XXX";
AzureCredentials cred = new AzureCredentialsFactory()
.FromServicePrincipal(UIConstants.ClientID,
UIConstants.Secret, UIConstants.Tenant,AzureEnvironment
.AzureGlobalCloud);
var azure = Azure.Configure()
.WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic)
.Authenticate(cred)
.WithSubscription(subscriptionId);
当我尝试像这样获取所有快照时
foreach (var s in azure.Snapshots.List())
{
//get snapshot
}
但是没有错误,循环也没有执行。 C# 中是否有任何代码示例可以获取所有快照信息。
【问题讨论】:
-
您 100% 确定快照存在?
-
感谢@mjwills 的回复。我在 azure 门户查看了快照,但没有快照。所以上面的代码是正确的但不存在任何快照'for'循环没有执行..这是正确的假设吗?
标签: c# azure .net-core azure-management-api